lnussbaum / xmpp4r

XMPP/Jabber Library for Ruby - please use:
http://github.com/xmpp4r/xmpp4r
Other
312 stars 1 forks source link

ruby 1.9.2 incompatible encoding regexp match #10

Open winding-lines opened 14 years ago

winding-lines commented 14 years ago

I am getting some encoding problems in REXML. Any idea on how to force the encodings to either UTF-8 or ASCII-8Bit?

Marius mseritan@de-co-de.com REXML::ParseException

<Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)>

/Users/myself/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rexml/source.rb:212:in match' /Users/myself/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rexml/source.rb:212:inmatch' /Users/myself/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:369:in pull' /Users/myself/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rexml/parsers/sax2parser.rb:92:inparse' /Users/myself/.rvm/gems/ruby-1.9.2-head/bundler/gems/xmpp4r-58529d875336b42d7dd5afe6bf577599f9305014-master/lib/xmpp4r/streamparser.rb:79:in parse' /Users/myself/.rvm/gems/ruby-1.9.2-head/bundler/gems/xmpp4r-58529d875336b42d7dd5afe6bf577599f9305014-master/lib/xmpp4r/stream.rb:75:inblock in start' ... Exception parsing Line:
Position: 0 Last 80 unconsumed characters: <presence from='shawn@some.com/Shawn’s MacBook Pro' to='me@some.com/ /Users/myself/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:441:in rescue in pull' /Users/myself/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:332:inpull' /Users/myself/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/rexml/parsers/sax2parser.rb:92:in parse' /Users/myself/.rvm/gems/ruby-1.9.2-head/bundler/gems/xmpp4r-58529d875336b42d7dd5afe6bf577599f9305014-master/lib/xmpp4r/streamparser.rb:79:inparse' /Users/myself/.rvm/gems/ruby-1.9.2-head/bundler/gems/xmpp4r-58529d875336b42d7dd5afe6bf577599f9305014-master/lib/xmpp4r/stream.rb:75:in `block in start'

bobanj commented 14 years ago

add

encoding: utf-8

at the beginning of the file

becatlibra-zz commented 14 years ago

add that to the beginning of what file? I am having an identical issue:

W, [2010-11-06T11:50:27.783913 #29449] WARN -- : EXCEPTION: REXML::ParseException

<Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)>

/usr/local/lib/ruby/1.9.1/rexml/source.rb:212:in `match'
/usr/local/lib/ruby/1.9.1/rexml/source.rb:212:in`match'
/usr/local/lib/ruby/1.9.1/rexml/parsers/baseparser.rb:425:in `pull'
/usr/local/lib/ruby/1.9.1/rexml/parsers/sax2parser.rb:92:in`parse'
/usr/local/lib/ruby/gems/1.9.1/gems/xmpp4r-0.5/lib/xmpp4r/streamparser.rb:79:in `parse'
/usr/local/lib/ruby/gems/1.9.1/gems/xmpp4r-0.5/lib/xmpp4r/stream.rb:75:in`block in start'
...
Exception parsing
Line: 
Position: 0
Last 80 unconsumed characters:

bobanj commented 14 years ago

At the beginning of the file where the error occurred add: #encoding: utf-8

becatlibra-zz commented 14 years ago

it is occurring after the code connects to the server. it is when the xmpp4r stream parser is parsing the incoming stanzas. Are you saying that I should be adding this to the streamparser.rb (part of the core of the xmpp4r module?)

bobanj commented 14 years ago

in every file that contains no ascii chars like for example шѓќч....so add it in the beginning of all files where there are non ascii chars...start with source.rb , baseparser.rb...it does no harm ...thats how 1.9 rolls ;) good luck

becatlibra-zz commented 14 years ago

The problem is that the characters that it cannot parse are coming in from the xmpp stream. They are not in a local file. The are in the incoming stanzas when the code connects to the xmpp server.

dotdoom commented 13 years ago

see https://github.com/ln/xmpp4r/issues#issue/3 for possible solution. Please report if it helps. Regards