• Encoding Convertor failed for utf-7 to utf-8

    From Suresh G@21:1/5 to All on Wed May 9 07:52:17 2018
    Hi,

    I am getting Encoding::ConverterNotFoundError, when try to convert utf-7 string to utf-8.

    I have a requirements of parsing the email and display the the email in rails app. I am using the gem https://github.com/mikel/mail for parsing the email. This is looking like core ruby issue, I thought to discuss understand here.

    Can somebody explain why there is no default converter for utf-7 to utf-8?. As utf-7 is mostly used in Emails, this should be there by default. If there is option to write custom Encoding::Converter, what is the procedure for it, I couldn't get something
    in docs.

    Ruby Version:2.3.o

    Irb:

    2.3.0 :053 > "".force_encoding('utf-7').encode('utf-8') Encoding::ConverterNotFoundError: code converter not found (UTF-7 to UTF-8)
    from (irb):53:in `encode'
    from (irb):53
    from /Users/suresh.gnanasekar/.rvm/rubies/ruby-2.3.0/bin/irb:11:in `<main>'


    Thanks,
    Suresh G

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Klemme@21:1/5 to Suresh G on Thu May 10 13:06:36 2018
    Oh, finally a real Ruby question here in Usenet! :-)

    On 09.05.2018 16:52, Suresh G wrote:

    I am getting Encoding::ConverterNotFoundError, when try to convert utf-7 string to utf-8.

    I have a requirements of parsing the email and display the the email in rails app. I am using the gem https://github.com/mikel/mail for parsing the email. This is looking like core ruby issue, I thought to discuss understand here.

    Can somebody explain why there is no default converter for utf-7 to utf-8?. As utf-7 is mostly used in Emails, this should be there by default. If there is option to write custom Encoding::Converter, what is the procedure for it, I couldn't get
    something in docs.

    I cannot remember having seen an UTF-7 email. In my neck of the woods
    it is usually either ASCII or some ISO-8859-1 variant.

    "UTF-7, a 7-bit encoding sometimes used in e-mail, often considered
    obsolete (not part of The Unicode Standard, but only documented as an informational RFC, i.e., not on the Internet Standards Track either);"

    https://en.wikipedia.org/wiki/Unicode#Unicode_Transformation_Format_and_Universal_Coded_Character_Set

    I would say, either you are dealing with an obscure source of emails or
    you mistook another format for UTF-7.

    Cheers

    robert

    --
    remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Suresh G@21:1/5 to Robert Klemme on Thu May 10 23:41:54 2018
    On Thursday, May 10, 2018 at 4:36:46 PM UTC+5:30, Robert Klemme wrote:
    Oh, finally a real Ruby question here in Usenet! :-)

    On 09.05.2018 16:52, Suresh G wrote:

    I am getting Encoding::ConverterNotFoundError, when try to convert utf-7 string to utf-8.

    I have a requirements of parsing the email and display the the email in rails app. I am using the gem https://github.com/mikel/mail for parsing the email. This is looking like core ruby issue, I thought to discuss understand here.

    Can somebody explain why there is no default converter for utf-7 to utf-8?. As utf-7 is mostly used in Emails, this should be there by default. If there is option to write custom Encoding::Converter, what is the procedure for it, I couldn't get
    something in docs.

    I cannot remember having seen an UTF-7 email. In my neck of the woods
    it is usually either ASCII or some ISO-8859-1 variant.

    "UTF-7, a 7-bit encoding sometimes used in e-mail, often considered
    obsolete (not part of The Unicode Standard, but only documented as an informational RFC, i.e., not on the Internet Standards Track either);"

    https://en.wikipedia.org/wiki/Unicode#Unicode_Transformation_Format_and_Universal_Coded_Character_Set

    I would say, either you are dealing with an obscure source of emails or
    you mistook another format for UTF-7.

    Cheers

    robert

    --
    remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/


    Thanks Robert!

    I am sure that email is in utf-7 format. The thing is that utf-7 type email is viewed properly with modern Email Clients(Outlook, Thunderbird) and they don't complain invalid or deprecated encodings. I am looking for a way to handle this gracefully in my
    Rails App as well. I understand this may not be part of Core of ruby as its deprecated encoding, but should be having procedure to handle it, may be having a way to write custom Encoding::Converter.

    Thanks,.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)