Menu

CharSet for text/plain parts

jMmsLib
fuel
2008-03-17
2013-05-01
  • fuel

    fuel - 2008-03-17

    I'm trying to generate a MMS-message using jmmslib and everything else is working ok, but I can't get international characters to show on my Nokia E70 phone.
    Here's the code that is making the text part:

    ------------------------
    MmsMessage mms = new MmsMessage();
    ...
    MmsPart p = new MmsPart();
    p.setPartCharset("ISO-8859-1");
    p.setPartContent(body.getBytes("ISO-8859-1"));
    p.setPartContentType(MmsMessage.CTYPE_TEXT_PLAIN);
    mms.addPart(p);
    ------------------------

    My code is based on the "Getting Started"-code.

    So I would like to use ISO-8859-1 or UTF-8 charset for text part, but the MMSC won't accept my MMS message (my program won't get any answer from MMSC) if line p.setPartCharset("ISO-8859-1"); exist (even if I set it to "US-ASCII") and if I remove the line, the message is received ok but the international characters won't show.

    getPartCharset() will print my charset ok if I check it using that method.

    Any ideas what I should do?

     
    • Andrea Zito

      Andrea Zito - 2008-03-17

      Actually jMmsLib supports only US-ASCII and UTF-8 charsets (this will change in the next release... more supported charsets :-) ).
      Also due to a stupid design decision I made at the beginning of the development, the values used for those charset are not the standard ones.
      For instance, US-ASCII is "us-ascii" and UTF-8 is "utf-8". To avoid problems I suggest you to use the constants defined in MmsMessage.
      Respectively MmsMessage.CHARSET_US_ASCII for US-ASCII and MmsMessage.CHARSET_UTF8 for UTF-8. Note that any other charset is not supported.

      In the future version of jMmsLib the values of the parameters (not only for charsets) will be more clear and enforced (thanks to enum).
      For the moment you have to live with this poor design.

      If you still have problems regarding charsets, please file a bug and provide the hex-dump of the messages generated with the 2 charsets.

      Thanks for using jMmsLib,
      Cheers Andrea

       
    • fuel

      fuel - 2008-03-18

      Thanks! I got it now working and international characters are shown right. The text part is now generated like this and it works:

      -----------------------------------------
      MmsPart p = new MmsPart();
      p.setPartCharset(MmsMessage.CHARSET_UTF8);
      p.setPartContent(body.getBytes("UTF-8"));
      p.setPartContentType(MmsMessage.CTYPE_TEXT_PLAIN);
      //Add the part to the message
      mms.addPart(p);
      -----------------------------------------

       

Log in to post a comment.