简体   繁体   中英

C# Serializer class Encoding Issue

I'm really not understanding where these characters are coming from. I am populating a custom class object and then serializing it to disk and getting strange characters in the result like this:

<Address1>_x0031_0028_x0020_N_x0020_30th_x0020_PL</Address1>

Where the correct answer is this:

<Address1>10028 N 30th PL</Address1>

When I step through the code, each of these object properties look good, it is only after they serialize that strange characters are injected. What I am not certain of, is if the characters originate from its source (a Nexus DB table which) and I just can't see the strange characters when stepping through the code in VS, or if indeed the characters are a result of serializing from the object itself. FYI, The object class source is actually a schema object that I've converted to a class.

Another note: this problem isn't occurring on every element, just a handful of them.

Thanks for any help on this.

Karl..

Solving my own problem. The problem was that I had defined a field in my schema as xs:ncname type, and then when serializing the values in the data source did not conform to this type so spaces and leading numbers were translated accordingly on serialization.

The solution was to correctly define the field as xs:string.

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