parseInt base convertion equivalent in haXe ?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

parseInt base convertion equivalent in haXe ?

Blue Sans douze
Hello list and haxers.

I wonder how can I make base convert in haXe.
In flash, I use to do :
var a:String = "abvrv";
var i:int = parseInt(a, 36);

How can I do the same in haXe ?

Thanks.
-Blue112

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: parseInt base convertion equivalent in haXe ?

Baluta Cristian
in haxe parseInt is Std.parseInt, but i don't know about the base.

On Sat, May 23, 2009 at 4:58 PM, Blue Sans douze <[hidden email]> wrote:
Hello list and haxers.

I wonder how can I make base convert in haXe.
In flash, I use to do :
var a:String = "abvrv";
var i:int = parseInt(a, 36);

How can I do the same in haXe ?

Thanks.
-Blue112

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: parseInt base convertion equivalent in haXe ?

Russell Weir
Fill up a Bytes object with the digits for your base, ie. for base 16 do

var base = Bytes.ofString("0123456789abcdef");

Then pass this to the constructor of haxe.BaseCode

var enc = new haxe.BaseCode(base);

Then, decode it with

var res = enc.decodeBytes( Bytes.ofString("deadc00ffee") );

Which will again return you a Bytes object.

There is also the shortcut BaseCode.decode, which creates a new
BaseCode object for every decode, so if you are only doing one
conversion, and you have no non-ascii chars in your digit set,
this is shorter, and does not require you to create Bytes objects...

var res = haxe.BaseCode.decode("deadc00ffee", "0123456789abcdef");

R

On Sat, May 23, 2009 at 11:14 PM, Baluta Cristian <[hidden email]> wrote:
in haxe parseInt is Std.parseInt, but i don't know about the base.

On Sat, May 23, 2009 at 4:58 PM, Blue Sans douze <[hidden email]> wrote:
Hello list and haxers.

I wonder how can I make base convert in haXe.
In flash, I use to do :
var a:String = "abvrv";
var i:int = parseInt(a, 36);

How can I do the same in haXe ?

Thanks.
-Blue112

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: parseInt base convertion equivalent in haXe ?

Russell Weir
By non-ascii, I meant not typeable characters... where is my coffee?

R

On Sun, May 24, 2009 at 10:27 AM, Russell Weir <[hidden email]> wrote:
Fill up a Bytes object with the digits for your base, ie. for base 16 do

var base = Bytes.ofString("0123456789abcdef");

Then pass this to the constructor of haxe.BaseCode

var enc = new haxe.BaseCode(base);

Then, decode it with

var res = enc.decodeBytes( Bytes.ofString("deadc00ffee") );

Which will again return you a Bytes object.

There is also the shortcut BaseCode.decode, which creates a new
BaseCode object for every decode, so if you are only doing one
conversion, and you have no non-ascii chars in your digit set,
this is shorter, and does not require you to create Bytes objects...

var res = haxe.BaseCode.decode("deadc00ffee", "0123456789abcdef");

R


On Sat, May 23, 2009 at 11:14 PM, Baluta Cristian <[hidden email]> wrote:
in haxe parseInt is Std.parseInt, but i don't know about the base.

On Sat, May 23, 2009 at 4:58 PM, Blue Sans douze <[hidden email]> wrote:
Hello list and haxers.

I wonder how can I make base convert in haXe.
In flash, I use to do :
var a:String = "abvrv";
var i:int = parseInt(a, 36);

How can I do the same in haXe ?

Thanks.
-Blue112

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org



--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: parseInt base convertion equivalent in haXe ?

Blue Sans douze
Thanks for that informations, I'll try it soon.

Thanks.
Blue112

2009/5/24 Russell Weir <[hidden email]>
By non-ascii, I meant not typeable characters... where is my coffee?

R


On Sun, May 24, 2009 at 10:27 AM, Russell Weir <[hidden email]> wrote:
Fill up a Bytes object with the digits for your base, ie. for base 16 do

var base = Bytes.ofString("0123456789abcdef");

Then pass this to the constructor of haxe.BaseCode

var enc = new haxe.BaseCode(base);

Then, decode it with

var res = enc.decodeBytes( Bytes.ofString("deadc00ffee") );

Which will again return you a Bytes object.

There is also the shortcut BaseCode.decode, which creates a new
BaseCode object for every decode, so if you are only doing one
conversion, and you have no non-ascii chars in your digit set,
this is shorter, and does not require you to create Bytes objects...

var res = haxe.BaseCode.decode("deadc00ffee", "0123456789abcdef");

R


On Sat, May 23, 2009 at 11:14 PM, Baluta Cristian <[hidden email]> wrote:
in haxe parseInt is Std.parseInt, but i don't know about the base.

On Sat, May 23, 2009 at 4:58 PM, Blue Sans douze <[hidden email]> wrote:
Hello list and haxers.

I wonder how can I make base convert in haXe.
In flash, I use to do :
var a:String = "abvrv";
var i:int = parseInt(a, 36);

How can I do the same in haXe ?

Thanks.
-Blue112

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org



--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org