• Question about --file-body body file charset

    By Kenji Sugimoto 1 decade ago

    I have question about using character set
    When I have sent Japanese character set using --body, It is O.K.  but it has limitation size. So, I tried to use --file-body parameter instead of --body.

    But it has garbage characters at Japanese characters(charset=shift-jis).  
    What kind of character set can I use for Japanese in body file?

    Thanks.

    • --file-body in Japan

      By Sami Salkosuo 1 decade ago

      Very good question and, by coincidence, a colleague from IBM Japan, Yasuhiro Onoda, solved this just last week.

      Here is the response from Yasuhiro:

      But I found mail from --file-body does not work well if a file contains multi byte characters.
      (In my cases, I need to write a mail in Japanese. )

      I checked the Mail.py file.

      These lines are used to read a file.
      -----------------------
         f=open(bodyFile)
         bodyLines=f.readlines()
      -----------------------

      But the readlines method of Jython does not work well to read multi byte characters.

      So I replaced the above lines with the following.
      -----------------------
          f= BufferedReader(InputStreamReader(FileInputStream(bodyFile)))
          bodyLines=[]
          line = f.readLine()
          while(line != None):
            bodyLines.append(line  + "\n")
            line = f.readLine()
      -----------------------

      I also added some classes to this line,
      -----------------------
      from java.io import File,FileInputStream,InputStreamReader,BufferedReader # for multi-byte capable
      -----------------------

      It may be dirty, but works fine for my Japanese mails,

       

      So you can get Japanese mails working.

      I included the change in the upcoming 4.2.1 release. The new version is in the release process and will be released as soon as it's approved.

       

      -Sami Salkosuo

      • Thanks. Resolved.

        By Kenji Sugimoto 1 decade ago

        I have replaced code in Mail.py and tested..
        Then,  my question was cleared and resolved by it.

        Thank you very much.

      • By Kenji Sugimoto 1 decade ago

        The same problem is occured again after install 5.0.5.
        UTF-8 problem was fixed by 5.0.3. is it related to this?

        Thank you.

        Kenji Sugimoto

        • By Kenji Sugimoto 1 decade ago

          typo-error 5.0.3->5.0.4.

          Regards.

        • By Sami Salkosuo 1 decade ago

          File is read using UTF-8. But if the file is in different charset like shift-jis then reading file using UTF-8 doesn't help.

          I'll fix this in the next version by adding –charset option that can be used with –file-body option.

          • By Kenji Sugimoto 1 decade ago

            I use 5.0.3.
            Thank you, Sami-san.