Hi;
I just spent about an hour in another place having to work around the fact that J# does not support vary many encodings - in String, Readers/Writers, etc. And what is really annoying is that .NET has this support and the J# team is in India so they are aware that the world uses languages other than English.
I wish they had fully implemented this.
- dave

Pet peeve of the day
Kah Geh
Please try:
OutputStreamWriter o =
new OutputStreamWriter(new FileOutputStream("data.out"), "utf-8");OutputStreamWriter o =
new OutputStreamWriter(new FileOutputStream("data.out"), "windows-1252"); String str = new String(new byte[4], "Shift_JIS");Work in java, not J# (there are others). That's why it's frustrating, it's there but J# didn't map some names.
thanks - dave
igkmahesh
-------------
To get the complete list of supported encodings refer http://msdn2.microsoft.com/en-us/library/86hf4sb8(en-US,VS.80).aspx
You can also, instead, specify the codepage to use for encoding. The table at http://msdn2.microsoft.com/en-us/library/86hf4sb8(en-US,VS.80).aspx lists the encodings and their associated codepages. Specify the codepage by prefixing it with "Cp". This convention should be familiar to users of the level of the library for which J# provides equivalent functionality.
Consider OutputStreamWriter:
The encodings can be passed to the OutputStreamWriter as a second parameter as follows:
import java.io.*;
{
public static void main(String[] args) throws Exception
{
String[] encoding =
{
// familiar names
"Unicode",
"UnicodeLittle",
"UnicodeBig",
"UTF7",
"UTF8",
"ASCII",
"8859_1",
"ISO-8859-1",
"ISO-Latin-1",
// (http://msdn2.microsoft.com/en-us/library/86hf4sb8(en-US,VS.80).aspx)
"Cp37", "Cp437", "Cp500", "Cp708", "Cp720", "Cp737",
"Cp775", "Cp850", "Cp852", "Cp855", "Cp857", "Cp858",
"Cp860", "Cp861", "Cp862", "Cp863", "Cp864", "Cp865",
"Cp866", "Cp869", "Cp870", "Cp874", "Cp875", "Cp932",
"Cp936", "Cp949", "Cp950", "Cp1026", "Cp1047", "Cp1140",
"Cp1141", "Cp1142", "Cp1143", "Cp1144", "Cp1145", "Cp1146",
"Cp1147", "Cp1148", "Cp1149", "Cp1200", "Cp1201", "Cp1250",
"Cp1251", "Cp1252", "Cp1253", "Cp1254", "Cp1255", "Cp1256",
"Cp1257", "Cp1258", "Cp1361", "Cp10000", "Cp10001", "Cp10002",
"Cp10003", "Cp10004", "Cp10005", "Cp10006", "Cp10007", "Cp10008",
"Cp10010", "Cp10017", "Cp10021", "Cp10029", "Cp10079", "Cp10081",
"Cp10082", "Cp12000", "Cp12001", "Cp20000", "Cp20001", "Cp20002",
"Cp20003", "Cp20004", "Cp20005", "Cp20105", "Cp20106", "Cp20107",
"Cp20108", "Cp20127", "Cp20261", "Cp20269", "Cp20273", "Cp20277",
"Cp20278", "Cp20280", "Cp20284", "Cp20285", "Cp20290", "Cp20297",
"Cp20420", "Cp20423", "Cp20424", "Cp20833", "Cp20838", "Cp20866",
"Cp20871", "Cp20880", "Cp20905", "Cp20924", "Cp20932", "Cp20936",
"Cp20949", "Cp21025", "Cp21866", "Cp28591", "Cp28592", "Cp28593",
"Cp28594", "Cp28595", "Cp28596", "Cp28597", "Cp28598", "Cp28599",
"Cp28603", "Cp28605", "Cp29001", "Cp38598", "Cp50220", "Cp50221",
"Cp50222", "Cp50225", "Cp50227", "Cp51932", "Cp51936", "Cp51949",
"Cp52936", "Cp54936", "Cp57002", "Cp57003", "Cp57004", "Cp57005",
"Cp57006", "Cp57007", "Cp57008", "Cp57009", "Cp57010", "Cp57011",
"Cp65000", "Cp65001",
};
{
try
{
OutputStreamWriter o = new OutputStreamWriter(new FileOutputStream("data.out"), encoding
System.out.println(encoding
o.write("Hello world");
o.close();
}
catch (java.io.UnsupportedEncodingException e)
{
System.out.println(encoding
}
}
}
}
Hope it answers your query...
Thanks.
Luke Hoban
Hi,
As per program manager's input,
----------
Here are the string mappings directly supported:
// Mapped to: Unicode LittleEndian
"Unicode"
"UnicodeLittle"
// Mapped to: Unicode BigEndian
"UnicodeBig",
// Mapped to: UTF8
"UTF8",
// Mapped to: UTF7
"UTF7",
// Mapped to: ASCII
"ASCII",
//Mapped to: Codepage 1252
"8859_1",
"ISO-8859-1",
"ISO-Latin-1",
"Cp1252",
"latin1",
//Mapped to: Big5
"Big5",
//Mapped to: GB2312
"GB2312",
//Mapped to: SJIS
"SJIS",
//Mapped to: iso-2022-jp
"JIS",
//Mapped to: ks_c_5601-1987
"KSC5601",
//Mapped to: default encoding
"Default",
"default",
Note that for everything else you can directly provide the Codepage prefixed with "Cp".
----------
Hope this helps you.
Thanks,
Kasinathan
VJ# Team
Roman Wienicke
I know that - I spent hours changing these in my code. But it would have been nice if J# supported all the encoding "names" that java does - it would save a number of people a lot of work. (In my case we have common source code and want our java to just compile.)
thanks - dave