Windows-1255 to UTF8 conversion

68 views
Skip to first unread message

ulewin

unread,
Dec 17, 2009, 11:28:57 AM12/17/09
to Israel.rb - the Israel Ruby & Rails Developers group
Need to convert windows-1255 encoded strings (e.g. =?windows-1255?B?
MDkuZG9j?=" ) to UTF-8

Any suggestion/idea would be appreciated

Uri

Adam Fine

unread,
Dec 17, 2009, 12:16:30 PM12/17/09
to isra...@googlegroups.com

require 'iconv'
Iconv.conv('utf-8', 'windows-1255', windows_1255_str)

-Adam
 
Uri

--

You received this message because you are subscribed to the Google Groups "Israel.rb - the Israel Ruby & Rails Developers group" group.
To post to this group, send email to isra...@googlegroups.com.
To unsubscribe from this group, send email to israelrb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/israelrb?hl=en.



ulewin

unread,
Dec 17, 2009, 3:19:46 PM12/17/09
to Israel.rb - the Israel Ruby & Rails Developers group
Hi Adam,

It does not work for me, i.e. the string "=?windows-1255?B?MDkuZG9j?
=" does not convert.
There seems to be a missing step, some kind of preparation action on
the string that would allow us to perform the iconv

Uri

On Dec 17, 7:16 pm, Adam Fine <a...@adamfine.net> wrote:
> On Thu, Dec 17, 2009 at 8:28 AM, ulewin <ule...@gmail.com> wrote:
> > Need to convert windows-1255 encoded strings (e.g. =?windows-1255?B?
> > MDkuZG9j?=" ) to UTF-8
>
> > Any suggestion/idea would be appreciated
>
> require 'iconv'
> Iconv.conv('utf-8', 'windows-1255', windows_1255_str)
>
> -Adam
>
> > Uri
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Israel.rb - the Israel Ruby & Rails Developers group" group.
> > To post to this group, send email to isra...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > israelrb+u...@googlegroups.com<israelrb%2Bunsu...@googlegroups.com>

ulewin

unread,
Dec 17, 2009, 4:28:37 PM12/17/09
to Israel.rb - the Israel Ruby & Rails Developers group
The missing step was mainly about base64 decoding
This worked for me:

require 'iconv'
require "base64"

base_string = "=?windows-1255?B?MDkuZG9j?="
base_string.gsub!('=?windows-1255?B?','').gsub!('?=','')

decoded_string = Base64.decode64(base_string)
output_string = Iconv.conv('utf-8', 'windows-1255',
decoded_string )

Reply all
Reply to author
Forward
0 new messages