Pet peeve of the day

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


Answer this question

Pet peeve of the day

  • wangzhongtao

    Hi;

    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


  • NilsP

    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


  • PatPennington

    Hi;

    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



  • WienerSchnitzel

    Hi,
    This is what our Program Manager Pratap Lakshman has to say on this issue...

    -------------
    J# surfaces all of the encodings supported on .NET.
    To get the complete list of supported encodings refer http://msdn2.microsoft.com/en-us/library/86hf4sb8(en-US,VS.80).aspx
     
    Users familiar with the level of the libraries for which J# provides equivalent functionality can refer to these encodings using names like Unicode, UnicodeLittle, UnicodeBig, UTF7, UTF8, ASCII, 8859_1, ISO-8859-1, etc.
    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.
     
    J# Example:
    Consider OutputStreamWriter:
    The encodings can be passed to the OutputStreamWriter as a second parameter as follows:

    import java.io.*;
     
    public class writer
    {
      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",
     
    // or use codepage number prefixed with "Cp". Refer table at:
    // (
    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",
        };
     
        for (int i = 0; i < encoding.length; i++)
        {

          try
          {
            OutputStreamWriter o = new OutputStreamWriter(new FileOutputStream("data.out"), encodingIdea);
            System.out.println(encodingIdea + " supported");
            o.write("Hello world");
            o.close();
          }
          catch (java.io.UnsupportedEncodingException e)
          {
            System.out.println(encodingIdea + " not supported");
          }
        }
      }
    }
    -------------

    Hope it answers your query...

    Thanks.


  • Pet peeve of the day