473,385 Members | 1,582 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

[C#]Unable to translate Unicode character \\u010B at index 53 to specified code page.

3
I have this strange message when I try to save XML-file with XmlWriter:

"Unable to translate Unicode character \\u2009 at index 478 to specified code page."

Why it's strange?
Because when the file is small (< 1KB) there is no problem and the file it's saved correctly but if file it's big (> 500KB) I get this message?
Can sombody help me?
snippet:

string strFile = @"c:\tmp\test.xml";
XmlWriter _xmlWriter;
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.Default;
_xmlWriter = XmlWriter.Create(strFile, settings);
xmlDoc.Save(_xmlWriter);
_xmlWriter.Close();
Aug 4 '08 #1
3 10613
Plater
7,872 Expert 4TB
Is it because there is not a translation from those unicode characters to whatever the default encoding is?
Aug 6 '08 #2
Kendo
3
Thank you :-)

Yes, you're right. The Unicode character (\u010B) have no translation in default encoding (ISO-8859-1).

But then the strange situation is when I have small file.

I made xml file:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<text>textul: <chr>ċ</chr><dec>267</dec><hex>10B</hex><dec1>99</dec1></text>
</root>

where:
<chr>-tag is Unicode character \u010B
<dec>-tag is decimal code of character \u010B
<hex>-tag is hexadecimal code of character \u010B

this file it's save with the Unicode character translated to entity &#x010B;
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<text>textul: <chr>&#x010B;</chr><dec>267</dec><hex>10B</hex><dec1>99</dec1></text>
</root>

And when the file have exactly 79 more same <text> nodes :) I get the "ugly" message from thread subject :).

What I do wrong? :-)

Thanks in advance
Aug 7 '08 #3
Kendo
3
well, I found how to :)
here it is the answer: stackoverflow.com
Expand|Select|Wrap|Line Numbers
  1.     XmlDocument doc = new XmlDocument();
  2.     doc.LoadXml(@"<xml>™</xml>");
  3.     using (MemoryStream ms = new MemoryStream())
  4.     {
  5.         XmlWriterSettings settings = new  XmlWriterSettings();
  6.         settings.Encoding = Encoding.GetEncoding("ISO-8859-1");
  7.         XmlWriter xw = XmlWriter.Create(ms, settings);
  8.         doc.Save(xw);
  9.         xw.Close();
  10.         Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));
  11.     }
Oct 24 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

27
by: EU citizen | last post by:
Do web pages have to be created in unicode in order to use UTF-8 encoding? If so, can anyone name a free application which I can use under Windows 98 to create web pages?
11
by: Patrick Van Esch | last post by:
Hello, I have the following problem of principle: in writing HTML pages containing ancient greek, there are two possibilities: one is to write the unicode characters directly (encoded as two...
24
by: chri_schiller | last post by:
I have a home-made website that provides a free 1100 page physics textbook. It is written in html and css. I recently added some chinese text, and since that day there are problems. The entry...
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
40
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages,...
6
by: archana | last post by:
Hi all, can someone tell me difference between unicode and utf 8 or utf 18 and which one is supporting more character set. whic i should use to support character ucs-2. I want to use ucs-2...
5
by: Les Caudle | last post by:
I've got some C# 2.0 code that has been working for a year. using (XmlWriter w = XmlWriter.Create("out.xml" ,settings)) { // many lines of code to write to w...
6
by: geegeegeegee | last post by:
Hi All, I have come across a difficult problem to do with extracting UniCode characters from RTF strings. A detailed description of my problem is below, if anyone could help, it would be much...
3
by: amija0311 | last post by:
Hi, I am new using DB2 9.1 database by windows base. I want to query the data that contain string then translate the string into integer using DB2. The problems is If the data is null, i got the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.