×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    7

    Nokia 6600 Crash and Chinese charactors display problem

    Dear all,

    I downloaded my application to the nokia 6600 handset which runs well on nokia 3650. Whenever i establish HttpConnection, the programme crashes and exit automatically without any error message.

    Also, StringItem can't display Chinese charactors. All the chinese charactors becomes squares. However, Chinese charactors can be displayed in TextFields's label.

    Does anyone encounter such problem on the 6600 handset?

    Joey

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    4
    I face similar problem that 6600 don't support convert to "utf-8"...


    And may be you try this little function written by me :-p
    Change from :
    msg = new String(bArray, "utf-8");
    To:
    msg = convertToUTF(bArray);


    /**
    * Convert an UTF-8 array to UTF-8 String for device not support UTF-8
    * String conversion, have the same effect as:
    * new String (inbytes, "utf-8")
    *
    * @author Alex Hong
    * @param inbytes UTF-8 bytes. e.g. (new String("ABC")).getBytes("utf-8");
    * @return An UTF-8 string
    */
    public static String convertToUTF(byte[] inbytes) {
    StringBuffer buff = null;
    char tmpbyte = 0;
    if (inbytes == null) {
    return "";
    } else {
    buff = new StringBuffer();
    for (int i=0; i<inbytes.length; i++) {
    if ((inbytes[i] & (byte)0x80) == (byte)0x0) {
    // 1 byte : 0xxxxxxx
    tmpbyte = (char)inbytes[i];
    buff.append(new Character(tmpbyte));
    } else if ((inbytes[i] & (byte)0xE0) == (byte)0xC0) {
    // 2 bytes : 110xxxxx 10xxxxxx
    if (inbytes.length <= i + 1 ||
    (inbytes[i+1] & (byte)0xC0) != (byte)0x80) {
    // Error, skip
    buff.append("?");
    } else {
    tmpbyte = (char)((((char)(inbytes[i] & (byte)0x1F)) <<
    6) |
    (((char)(inbytes[i+1] & (byte)0x3F))));
    buff.append(new Character(tmpbyte));
    i = i+1;
    }
    } else if ((inbytes[i] & (byte)0xF0) == (byte)0xE0) {
    // 3 bytes : 1110xxxx 10xxxxxx 10xxxxxx
    if (inbytes.length <= i + 2 ||
    (inbytes[i+1] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+2] & (byte)0xC0) != (byte)0x80) {
    // Error, skip
    buff.append("?");
    } else {
    tmpbyte = (char)((((char)(inbytes[i] & (byte)0x0F)) <<
    12) |
    (((char)(inbytes[i+1] & (byte)0x3F)) << 6) |
    (((char)(inbytes[i+2] & (byte)0x3F))));
    buff.append(new Character(tmpbyte));
    i = i+2;
    }
    } else if ((inbytes[i] & (byte)0xF8) == (byte)0xF0) {
    // 4 bytes : 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
    if (inbytes.length <= i + 3 ||
    (inbytes[i+1] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+2] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+3] & (byte)0xC0) != (byte)0x80) {
    // Error, skip
    buff.append("?");
    } else {
    tmpbyte = (char)((((char)(inbytes[i] & (byte)0x07)) <<
    18) |
    (((char)(inbytes[i+1] & (byte)0x3F)) << 12) |
    (((char)(inbytes[i+2] & (byte)0x3F)) << 6) |
    (((char)(inbytes[i+3] & (byte)0x3F))));
    buff.append(new Character(tmpbyte));
    i = i+3;
    }
    } else if ((inbytes[i] & (byte)0xFC) == (byte)0xF8) {
    // 5 bytes : 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
    if (inbytes.length <= i + 4 ||
    (inbytes[i+1] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+2] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+3] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+4] & (byte)0xC0) != (byte)0x80) {
    // Error, skip
    buff.append("?");
    } else {
    tmpbyte = (char)((((char)(inbytes[i] & (byte)0x03)) <<
    24) |
    (((char)(inbytes[i+1] & (byte)0x3F)) << 18) |
    (((char)(inbytes[i+2] & (byte)0x3F)) << 12) |
    (((char)(inbytes[i+3] & (byte)0x3F)) << 6) |
    (((char)(inbytes[i+4] & (byte)0x3F))));
    buff.append(new Character(tmpbyte));
    i = i+4;
    }
    } else if ((inbytes[i] & (byte)0xFE) == (byte)0xFC) {
    // 6 bytes : 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx
    10xxxxxx
    if (inbytes.length <= i + 5 ||
    (inbytes[i+1] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+2] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+3] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+4] & (byte)0xC0) != (byte)0x80 ||
    (inbytes[i+5] & (byte)0xC0) != (byte)0x80) {
    // Error, skip
    buff.append("?");
    } else {
    tmpbyte = (char)((((char)(inbytes[i] & (byte)0x03)) <<
    30) |
    (((char)(inbytes[i+1] & (byte)0x3F)) << 24) |
    (((char)(inbytes[i+2] & (byte)0x3F)) << 18) |
    (((char)(inbytes[i+3] & (byte)0x3F)) << 12) |
    (((char)(inbytes[i+4] & (byte)0x3F)) << 6) |
    (((char)(inbytes[i+5] & (byte)0x3F))));
    buff.append(new Character(tmpbyte));
    i = i+5;
    }
    } else {
    // Error, skip
    buff.append("?");
    }
    }
    }
    if (buff == null) {
    return null;
    } else {
    return buff.toString();
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×