B
Bill George
Any Java code examples for converting Unicode to ASCII?
Many thanks.
Many thanks.
Bill George said:Any Java code examples for converting Unicode to ASCII?
Bill said:Any Java code examples for converting Unicode to ASCII?
Michael said:Bill said:Any Java code examples for converting Unicode to ASCII?
String unicode = "Unicode: \u30e6\u30eb\u30b3\u30fc\u30c9";
byte[] bytes = String.getBytes("US_ASCII");
Any Java code examples for converting Unicode to ASCII?
Many thanks.
Any Java code examples for converting Unicode to ASCII?
Bill said:Any Java code examples for converting Unicode to ASCII?
RC said:There are only 255 = 2 to power 8 (from 00 to ff) values in ASCII.
Unicode are from 0000 to ffff (2 to power 16 = ??).
Everything in Unicode from 0000 to 00ff are exactly the same as
ASCII. You can not convert unicode to ASCII which value greater than
00ff, right?!
Almost right...everything from 0x0000 through 0x007F are exactly the
same as ASCII. Everything from 0x0000 through 0x00FF is the same as ISO
Latin 1.
The safest way to create ASCII text is to use the built-in converters, ie
byte[] ascii = someString.getBytes("ASCII");
Joona said:Isn't ISO Latin 1 a superset of ASCII? In that case you could simply say
that everything from 0x0000 through 0x00FF is the same as ISO Latin 1.
String unicode = "Unicode: \u30e6\u30eb\u30b3\u30fc\u30c9";
byte[] bytes = String.getBytes("US_ASCII");
Roedy Green said:String unicode = "Unicode: \u30e6\u30eb\u30b3\u30fc\u30c9";
byte[] bytes = String.getBytes("US_ASCII");
does anything but Java source code understand \uxxxx sequences?
byte[] bytes = String.getBytes("US_ASCII");
does anything but Java source code understand \uxxxx sequences?
Property files do - and it's also used in C#.
Roedy Green said:String unicode = "Unicode: \u30e6\u30eb\u30b3\u30fc\u30c9";
byte[] bytes = String.getBytes("US_ASCII");
does anything but Java source code understand \uxxxx sequences?
KC said:String unicode = "Unicode: \u30e6\u30eb\u30b3\u30fc\u30c9";
byte[] bytes = String.getBytes("US_ASCII");
does anything but Java source code understand \uxxxx sequences?
Property files do - and it's also used in C#.
Be careful with the escape sequences though - you could break your code if
the unicode escapes is converted to new lines, quotes and etc.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.