<div dir="ltr"><div>Hi,</div><div><br></div><div>I'm bit confused about the behaviour of xmerl_scan when dealing with utf-8 data. In short, the XML parser chokes when it encounters a "ü", but not if I specify the encoding as "latin1". Other parsers in other languages (e.g. nokogiri in Ruby) seem to handle this just fine. I've also run the sample XML through various web validators, and they all say it is valid.</div><div><br></div><div>Is this a bug in xmerl or am I missing something obvious?</div><div><br></div><div>Example session below:</div><div><br></div><div><div><font face="monospace, monospace">danabr@danabr ~> echo -n "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>ümlaut</root>" > /tmp/test.xml</font></div><div><font face="monospace, monospace">danabr@danabr ~> erl</font></div><div><font face="monospace, monospace">Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">Eshell V6.3  (abort with ^G)</font></div><div><font face="monospace, monospace">1> {ok, S} = file:read_file("/tmp/test.xml").</font></div><div><font face="monospace, monospace">{ok,<<"<?xml version=\"1.0\" encoding=\"UTF-8\"?><root>ümlaut</root>"/utf8>>}</font></div><div><font face="monospace, monospace">2> xmerl_scan:string(unicode:characters_to_list(S)).</font></div><div><font face="monospace, monospace">3414- fatal: {error,{wfc_Legal_Character,{error,{bad_character,252}}}}</font></div><div><font face="monospace, monospace">** exception exit: {fatal,{{error,{wfc_Legal_Character,{error,{bad_character,252}}}},</font></div><div><font face="monospace, monospace">                           {file,file_name_unknown},</font></div><div><font face="monospace, monospace">                           {line,1},</font></div><div><font face="monospace, monospace">                           {col,47}}}</font></div><div><font face="monospace, monospace">     in function  xmerl_scan:fatal/2 (xmerl_scan.erl, line 4102)</font></div><div><font face="monospace, monospace">     in call from xmerl_scan:scan_char_data/5 (xmerl_scan.erl, line 2703)</font></div><div><font face="monospace, monospace">     in call from xmerl_scan:scan_content/11 (xmerl_scan.erl, line 2615)</font></div><div><font face="monospace, monospace">     in call from xmerl_scan:scan_element/12 (xmerl_scan.erl, line 2128)</font></div><div><font face="monospace, monospace">     in call from xmerl_scan:scan_document/2 (xmerl_scan.erl, line 570)</font></div><div><font face="monospace, monospace">     in call from xmerl_scan:string/2 (xmerl_scan.erl, line 286)</font></div><div><font face="monospace, monospace">3> xmerl_scan:string(unicode:characters_to_list(S), [{encoding, "latin1"}]).</font></div><div><font face="monospace, monospace">{{xmlElement,root,root,[],</font></div><div><font face="monospace, monospace">             {xmlNamespace,[],[]},</font></div><div><font face="monospace, monospace">             [],1,[],</font></div><div><font face="monospace, monospace">             [{xmlText,[{root,1}],1,[],"ümlaut",text}],</font></div><div><font face="monospace, monospace">             [],"/home/danabr",undeclared},</font></div><div><font face="monospace, monospace"> []}</font></div></div><div><br></div><div>//Daniel Abrahamsson</div></div>