简体   繁体   中英

How to get unicode value used XmlReader class in C#

I have used XmlReader Class and have to Parsed font file Svg format. I could not parsed glyph tags attribute unicode string value

 <svg><font><glyph unicode="&#xe600;" /></font></svg>

I had tried

 if (xmlReader.GetAttribute("unicode") != null)
 {
 string unicode = xmlReader.GetAttribute("unicode");
  }

Got output unicode =""

I need exactly unicode string value.

Can anyone Answer please !

There's nothing wrong with the response - that's the Unicode character represented by the UTF-8 E600 hex value. This value is in the private use area which means there is no standard glyph that can be shown, so a default glyph is used.

A char is a 16-bit number representing a UTF16 codepoint, so you already have the codepoint. If you want to format it as a hex string you can use the x4 format, eg:

char theChar=unicode.Chars[0];
string hexString=String.Format("{0:x4}",theChar);

This will return E600 .

If you want to output the same string as the original you can use "&#x{0x:4}"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM