473,611 Members | 2,236 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

encoding problems (utf-8)

I have a problem with utf-8 enconding and I don't know
what to do in order to make it work.

I want to open a new window with excel data so the user
can choose to save it local. Everything works fine, the
new window, the excel data appears, but, extended
characters are wrong.

I call the window from an aspx page using this:

<script language='javas cript'> window.open
('excelviewer.a spx?nif=...&id= .....

then, excelviewer.asp x.cs has this:

private void showExcel (DataSet ds) {
Response.ClearC ontent();
Response.ClearH eaders();
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Append Header("Content-
Disposition", "inline;filenam e=consulta.csv" );
Response.Conten tEncoding = System.Text.Enc oding.UTF8;
Response.Charse t = "utf-8";
//Response.Append Header("Content-Transfer-Encoding",
Response.Conten tEncoding.Encod ingName);
System.Globaliz ation.CultureIn fo culture = new
System.Globaliz ation.CultureIn fo("es");

System.IO.Strin gWriter sw = new System.IO.Strin gWriter
(culture);
HtmlTextWriter htmlw = new HtmlTextWriter( sw);
htmlw.AddAttrib ute
(HtmlTextWriter Attribute.Title , "Consulta") ;

DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderContro l(htmlw);

Response.Write( htmlw.InnerWrit er);
Response.Flush( );
Response.Close( );
}

That is the C# code, it works fine, the new window
appears with the excel content and the correct columns
and rows, but several extended characters appears badly.
I saw on IE view and there is no AutoSelect and UTF-8 is
selected instead.

Also on the aspx I put this <%@ Page language="c#"
ResponseEncodin g="UTF-8" Codebehind="exc elviewer.aspx.c s"
AutoEventWireup ="false"
Inherits="ROCAM P.Formularis.ex celviewer" %> but nothing.

Here you can find some explample of the output, it is
just a part of the columns, and only the first line:

NIF NOM ESTAT CARNET NÃsMERO MOVIMENT BORSA DATA
INICI
38112294Y David Bernal Manero Finalitzat BÃ?SIC
BA100000/03 Expedició No 21/01/2004

it should look like this:

NIF NOM ESTAT CARNET NÚMERO MOVIMENT BORSA DATA
INICI
38112294Y David Bernal Manero Finalitzat BÀSIC
BA100000/03 Expedició No 21/01/2004


If anyone could give me some advice, I'll appreciate it
very much.

thanx in advance,

Guillermo.

Nov 18 '05 #1
2 3275
Yes, utf-8 must work fine for me, I used previously in
xsl trasformations and it was fine (without utf-8 the xsl
transformation was unsuccesful), that's why I tried to
put it everywher, because I thought in somewhere the data
changed. I found that the problem is in the writer, I
mean, the data is ok just before writing, I check it
using watches at debugging.

I also tried another way later. Create a phisical csv
file (previously done on another application with utf-8
too, and works fine), and the same happened: in
StreamWriter.Wr iteLine(data), data is perfectly fine (as
appears in a debuger watch) but after the WriteLine,
opening the csv file shows some characters badly.

So, I don't think it is because of using utf-8. Anyway
I'll try with others codes. Thanx.
-----Original Message-----
Hi
utf-8 is selected because you say so all over your code! (well, even if you didn't it's default anyway.)change the page *and* request/response encoding from utf- 8 to your *local language encoding*.modify the "globalizat ion" section of the web.config file appropriately to have it fixed once and for all.
dimitris

"Guillermo Rosich Capablanca" wrote:
I have a problem with utf-8 enconding and I don't know
what to do in order to make it work.

I want to open a new window with excel data so the user can choose to save it local. Everything works fine, the new window, the excel data appears, but, extended
characters are wrong.

I call the window from an aspx page using this:

<script language='javas cript'> window.open
('excelviewer.a spx?nif=...&id= .....

then, excelviewer.asp x.cs has this:

private void showExcel (DataSet ds) {
Response.ClearC ontent();
Response.ClearH eaders();
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Append Header("Content-
Disposition", "inline;filenam e=consulta.csv" );
Response.Conten tEncoding = System.Text.Enc oding.UTF8; Response.Charse t = "utf-8";
//Response.Append Header("Content-Transfer- Encoding", Response.Conten tEncoding.Encod ingName);
System.Globaliz ation.CultureIn fo culture = new
System.Globaliz ation.CultureIn fo("es");

System.IO.Strin gWriter sw = new System.IO.Strin gWriter (culture);
HtmlTextWriter htmlw = new HtmlTextWriter( sw);
htmlw.AddAttrib ute
(HtmlTextWriter Attribute.Title , "Consulta") ;

DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables[0];
dg.DataBind();
dg.RenderContro l(htmlw);

Response.Write( htmlw.InnerWrit er);
Response.Flush( );
Response.Close( );
}

That is the C# code, it works fine, the new window
appears with the excel content and the correct columns
and rows, but several extended characters appears badly. I saw on IE view and there is no AutoSelect and UTF-8 is selected instead.

Also on the aspx I put this <%@ Page language="c#"
ResponseEncodin g="UTF-8" Codebehind="exc elviewer.aspx.c s" AutoEventWireup ="false"
Inherits="ROCAM P.Formularis.ex celviewer" %> but nothing.
Here you can find some explample of the output, it is
just a part of the columns, and only the first line:

NIF NOM ESTAT CARNET NÃfsMERO MOVIMENT BORSA DATA INICI
38112294Y David Bernal Manero Finalitzat BÃf?SIC
BA100000/03 ExpediciÃf³ No 21/01/2004

it should look like this:

NIF NOM ESTAT CARNET NÃsMERO MOVIMENT BORSA DATA INICI
38112294Y David Bernal Manero Finalitzat BÃ?SIC
BA100000/03 Expedició No 21/01/2004


If anyone could give me some advice, I'll appreciate it very much.

thanx in advance,

Guillermo.


.

Nov 18 '05 #2
Guillermo Rosich Capablanca wrote:
I have a problem with utf-8 enconding and I don't know
what to do in order to make it work.

I want to open a new window with excel data so the user
can choose to save it local. Everything works fine, the
new window, the excel data appears, but, extended
characters are wrong.


A quick test shows that Excel (XP) seems to be the problem. Excel blindly
opens any CSV file using the OS default codepage.
--
Joerg Jooss
jo*********@gmx .net

Nov 18 '05 #3

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

Similar topics

2
2383
by: Iain | last post by:
Folks, I'm having a problem with charset encodings that I desparately need some help with. I don't even pretend to know the basics about charsets, so please forgive my ignorance. I am transforming XML source into XHTML using an encoding of iso-8859-1 and when I browse (using Mozilla 1.x) I see strange, accented 'A' characters preceeding some characters generated from an entity reference. If I use utf-8, things get a lot worse: even my...
1
2671
by: Neet | last post by:
Hi, I am currently working on sending an XML request to a server and it responds with an xml response. This request and response use ISO-8859-1 encoding. The xml request and response need to match. The Response i get, replaces some of the French text with <e9> characters, and the request that i send them has <c3><a9> as the characters which identify the French text. When i convert both to a string, they return the identical text, but the xml...
13
3304
by: bussiere bussiere | last post by:
hi i'am making a program for formatting string, or i've added : #!/usr/bin/python # -*- coding: utf-8 -*- in the begining of my script but str = str.replace('Ç', 'C') str = str.replace('é', 'E')
7
4459
by: EmeraldShield | last post by:
We have an application that uses UTF8 everywhere to load / save / process documents. One of our clients is having a problem with BIG Encoded files being trashed after running through our app. Indeed I have verified that if I go to a website in Taiwan and save the file in BIG5 and then just load / save the file with a UTF8 text reader / write some bytes are modified. How can I correct this? It was my understanding the UTF8 was...
0
1400
by: kellner | last post by:
Hello, I'm parsing a chunk of XML code and would like to add attribute values to individual tags if these are lacking. This is with perl 5.8.6, libxml2 2.6.17, XML::LibXML 1.58. Basically, I have the parser add the attribute values to the respective nodes and then use the toString method of XML::LibXML::Document to write the modified text to a scalar. Both the original and the modified text evaluate properly as utf8, but the modified...
4
2339
by: WH | last post by:
Hi, I use a Streamreader in VB2005 to read text files I made before in NotePad, but it can't read characters like "é" or "ç". They are omitted, or replaced by other characters. I tried different encodings, but I can't fix the problem. In VB6 everything works well. I live in Belgium (Duch language). Can anyone help me? Thanks, WH
10
3320
by: amygdala | last post by:
Hi all, Another problem that has been bugging me for a while now, but which I swept under the rug too long too now is a mail encoding problem at my (shared) webhost. The problem is that on different occassions when I send the exact same mail (same e-mail address, same name, same body content) through my site's contactform it produces the wellknown strange characters instead of the intended diacritical characters. This problem also...
15
6033
by: Bexm | last post by:
Hello I have searched through this forum and it seems some people are having similar problems to me but none of the fixes are fixing mine..! :( I have a table in my database that has two xml fields. I have two bits of generated XML I want to store.. the first one has "<?xml version="1.0" encoding="utf-8" ?>" as its declaration and the second has "<?xml version="1.0" encoding="utf-16" ?>" First time round these both get added to the...
0
1598
by: damonwischik | last post by:
I use emacs 22 and python-mode. Emacs can display utf8 characters (e.g. when I open a utf8-encoded file with Chinese, those characters show up fine), and I'd like to see utf8-encoded output from my python session. From googling, I've found references to * locale.getdefaultlocale(), which is ('en_GB', 'cp1252') * sys.stdout.encoding, which is None * the environment variables LANG, LC_CHARSET and LC_ALL....
0
8097
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8596
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8561
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8240
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8411
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5527
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4042
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2546
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
0
1411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.