Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

illegal characters in XML using UTF-8

Posted on 2011-05-05
8
Medium Priority
?
75 Views
Last Modified: 2016-06-02
What are the
illegal characters in XML using UTF-8
0
Comment
Question by:ecandel420
5 Comments
 

Author Comment

by:ecandel420
ID: 35701916
Aside from &,",',Carriage Return, Line Feed, < and >

Entity      Entity Reference      Hex      Description      Value
amp      &amp;        26            ampersand (&)      U+0026
lt      &lt;            3C      less-than (<)                           U+003C
apos      &apos;        27      apostrophe (')      U+0027
quot      &quot;       22      double quote (")       U+0022
gt      &gt;         3E                      greater-than (>)      U+003E
¿                   OA                         Carriage return (¿)      
¿                   OD                          Line Feed  (¿)      
0
 
LVL 27

Accepted Solution

by:
BigRat earned 2000 total points
ID: 35705222
Converting the UTF-8 into Unicode, then the illegal Unicode character positions are documented at
http://www.w3.org/TR/2006/REC-xml11-20060816/#charsets

Simply put anything under hex 20 other than CR LF and TAB is illegal, then from hex 80 to 9F except 85 also and then various "gaps" between the "code pages".

But UTF-8 is an encoding of Unicode whereby the Unicode positions are encoded in 1 to 6 bytes. The start byte determines how many other bytes follow and these bytes must be in specific ranges in order to tell if one byte is out of sequence. See http://en.wikipedia.org/wiki/UTF-8#Invalid_byte_sequences.

If you want to check a UTF-8 string for complete consistancy with the standards you'll need to implement a UTF-8 to Unicode converter and the test each Unicode character against the standard (say in a bit map) which you can download from www.unicode.org.

HTH
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 35705347
This article can shed some light on the issues that we frequently encounter.
http://www.joelonsoftware.com/articles/Unicode.html

A lot of times people seem to thing Unicode (UTF-8) is needed when it really is not needed.  Example: You are producing XML with Western European characters, but not Chinese or Korean.  In that case you can use ISO8859-1 and things should work out fine.

What programming languages are you using?  If you use PHP I can give you code examples showing some ways of getting past the problem.  One strategy, no matter what language you use, is to replace the illegal unicode characters with numbered entities like &#0A; etc...
0
 

Expert Comment

by:EE_AutoDeleter
ID: 41628746
I've requested that this question be deleted for the following reason:

                           
No comment has been added to this question in more than 21 days, so it is now classified as abandoned and is now flagged for deletion.


If there is a valid solution, please OBJECT and indicate the comments that are, or would otherwise lead to, a solution.


Use the specific format https:#axxxxxxxx for comment ID(s).


Also, please don't object simply because the author did not respond to your comment. While we understand this is frustrating, unfortunately we cannot force the author to return to the question. Unless you feel you have presented a valid, verifiable solution we'll simply delete the question.


Experts-Exchange Auto Deleter
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 41628747
Wow, since this is like five years old, the state of the art has advanced a bit.  I think BigRat gives a good answer here.  Also, numbered entities have always worked with XML.  And since the long-ago time of this question, I've written an article on UTF-8 and its role in character set encoding.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question