473,586 Members | 2,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

characters with accent sor umlauts get written wrong

I am using the code snippet below. If the datagrid displays words with
french accent 'e' like 'cafe' or 'Toshiba Protege', the file test.xls
displays these e's as garbled 3 characters.

Do I need to do some formatting or specify some code page, langauge..etc?

StreamWriter sr;
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new
HtmlTextWriter( sw);
myDataGrid.Rend erControl(htw); sr =
File.CreateText ("test.xls") ;
sr.WriteLine(sw .ToString());
John Dalbeg
Feb 15 '06 #1
1 1849
Thus wrote John,
I am using the code snippet below. If the datagrid displays words with
french accent 'e' like 'cafe' or 'Toshiba Protege', the file test.xls
displays these e's as garbled 3 characters.

Do I need to do some formatting or specify some code page,
langauge..etc?
File.CreateText () uses UTF-8 as character encoding. It seems Excel (I'm using
2003 SP2) doesn't correctly decode such a file if it is simply opened by
double clicking. But if you open the file from within Excel, you can choose
the correct encoding and process the file successfully.
StreamWriter sr;
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new
HtmlTextWriter( sw);
myDataGrid.Rend erControl(htw); sr =
File.CreateText ("test.xls") ;
sr.WriteLine(sw .ToString());


As a workaround, simply create your text file with a Windows specific encoding
(Windows-125x), usually exposed as Encoding.Defaul t.

sr = new StreamWriter("t est.xls", false, Encoding.Defaul t);

If you can't use the default settings for file access applied by StreamWriter
internally, create a FileStream with your specific accesss flags set first,
and pass that to your StreamReader:

sr = new Streamwriter(fi leStream, Encoding.Defaul t);

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
Feb 17 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

114
7680
by: muldoon | last post by:
Americans consider having a "British accent" a sign of sophistication and high intelligence. Many companies hire salespersons from Britain to represent their products,etc. Question: When the British hear an "American accent," does it sound unsophisticated and dumb? Be blunt. We Americans need to know. Should we try to change the way we...
5
10431
by: Matthew Shaw | last post by:
We have a web-based reporting application written in J2EE that writes out to excel using response.setContentType ("application/vnd.ms-excel; ")…. The problem is that where we have any special characters in our report result set E.g umlauts and accents ( ASCII values 128 to 165 ) this data is corrupted, and does not appear correctly. The...
0
2093
by: Markus Wollny | last post by:
Hi! Sorry to bother you, but I just don't know how to get tsearch2 configured correctly for my setup. I've got a 7.4.3 database-cluster initdb'ed with de_DE@euro as locale, the database is with Unicode encoding. I made and installed contrib/tsearch2 after installing the dump/reload-patch...
2
1660
by: Alan Searle | last post by:
For reporting purposes I generate XML from an MS-Access 2002 database and find that in this way I can format and display the data no problem with a XSL/HTML template. Perfect! However, then I found that I needed to replace my automatic MS-Access output with a customised dump of the XML and find that I am now having a problem with special...
0
1757
by: Fabrice | last post by:
Hello, (Alain) Tis is a part of my code to retrieve text from hastable in memory cache, by reading (befor) a resources file. Thanks for your help. /1/ The resources file * I have create a .TXT file with Keys/Values
8
5778
by: santiago | last post by:
Editing XML with special characters like ç á ñ Hello. I have to code a multilanguage website. As it will be very static, I set things up so everything is loaded from an XML file. However, as soon as I tried to start typing in the text in spanish, french and polish, I realized that no XML editor I knew would let me type and output unicode...
1
3966
by: Roberto Rocco | last post by:
Hello, I'm using VS 2005 and I need to send a mail body which contains german umlauts (ä,ö,ü). When I receive the mail in Outlook 2003 (english operating system) I always get a '|' or other similar symbols instead of the expected umlaut. I'm using Sstem.Net.Mail and I already tried something like this: string body = "this is some...
10
3108
by: Mike Schilling | last post by:
I've created a simple .NET 1.1 web service using VS.NET 2003: it has one method that takes a string parameter. It iterates through the input string, turning each character into hex and appending it to an output string, and returns the result. I now send this service SOAP messages containing non-ASCII characters in the field that becomes...
13
3520
by: TK | last post by:
Hi, how can I handle multibyte characters like ä, ü (german vowel mutation)? This does't work: switch(c) case 'ä': ... some action
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.