$ perl -le 'use warnings; my $x=chr(0x1FFFF)'
Unicode character 0x1ffff is illegal at -e line 1.
XML supports UTF-8 so I check for valid UTF-8 string and use it in XML if valid. Right? No!!!
There are some "non-illegal" characters that are perfect valid in UTF-8 (or even in the plain old ASCII), but are invalid for XML. The most obvious 0x00. Here is what W3C XML 1.0 specification say:
[2] Char
I spend some time playing with it and the result is XML::Char->valid(). The dev Data::asXML is using it now. If you you want, have a look at the test suit and try to break it.
UTF-8 (Score:1)
I'm sorry to disappoint you, but
Perl_is_utf8_stringcan't be used to check for well-formed UTF-8. Perls utf8 encoding form is superset of Unicode and ISO/IEC 10646. Perls encoding form supports codepoints up to 2**64-1 and has no problems with encoded UTF-16 surrogates or any other permanently reserved codepoints.Re: (Score:1)
Baf, I'm not disappointed. Nothing can be more disappointing than encoding problems...
Hansen can you have a loot at http://github.com/jozef/String-isUTF8/blob/master/t/01_String-isUTF8.t [github.com] and send a patch with failing tests?
Re: (Score:1)
Wrong wrong wrong (Score:1)
Don’t look at the UTF8 flag. The UTF8 flag does not mean what you think it means. You can have a perfectly valid Unicode string that does not have its UTF8 flag set, and you can have a JPEG image in a string that does have its UTF8 flag set. The UTF8 flag is a lie. It should not have been called the UTF8 flag. There is no flag in Perl that means what you think the UTF8 flag means. Don’t look at the UTF8 flag.
What you want to do is very simple:
Re: (Score:1)
Re: (Score:1)
I misunderstood where the problem is in the code, but it’s still wrong. Since it’s XS, you specifically do need to look at the flag, explicitly:
Re: (Score:1)