 |
|
|
 |
|
 |
public static string unicode_iso8859(string src) { Encoding iso = Encoding.GetEncoding("iso8859-1"); Encoding unicode = Encoding.Unicode; byte[] unicodeBytes = unicode.GetBytes(src); byte[] isoBytes = Encoding.Convert(unicode, iso, unicodeBytes); char[] isoChars = new char[iso.GetCharCount(isoBytes, 0, isoBytes.Length)]; iso.GetChars(isoBytes, 0, isoBytes.Length, isoChars, 0); } test with «»?©ø“?”£¾•†™ (hope that saves ok)
|
|
|
|
 |
|
|
 |
|
 |
I have devanagri(Hindi) words stored in the postgres database whose encoding type is already set to utf8. When I read and display those characters in asp.net without using any encoding method it gives all junk character.
But when I use the functions defined in the article on the text read from the database it displays almost more than half of the devanagri characters and displays them correctly. But it also does not recognize some devanagri characters and displays them incorrectly.
What can we do so that it recognizes all devanagri characters and displays them correctly.Please suggest.
|
|
|
|
 |
|
 |
I have a problem in replacing a string comming from stream reader with arabic character
and then create a word document and write the string after replacing using the stream writter. The arabic character appairs in strange format
|
|
|
|
 |
|
 |
I have a database which is configured with locale en_US.850.
Understand that characters are not probably stored in the database with the correct encoding format. But using classic ASP page, input Chinese (Big5) words are directly inserted into the database without any conversion (i.e. garbage in garbage out). So, those data is viewed probably from another classic ASP page, as long as the IE browser is using the BIG5 encoding.
However, problem comes when I changed my application to use ASP.NET. In .NET, it is not garbage in garbage out. As the data is not probably encoded and stored in the DB, when the front-end show the data, ASP.NET will encode it to UTF-8 by default. That will make the data wrongly encoded. Even I change the responseEncoding in the web.config file to BIG5, it don't work as well, again, the data is not probably encoded.
I have considered your solution. But the point is there have been a huge data set that are stored inside which is not iso-8859-1 encoded, and it is not possible to convert them at this moment.
Is there workaround for this situation, provided that the database locale remains unchanged?
cupsnoodles
|
|
|
|
 |
|
 |
I have run into a similar problem in a recent project. Has anyone run into this problem and found a solution yet?
-- Steven Hunt
|
|
|
|
 |
|
 |
:|Hello,
After a long search, I found this article i thought to solve my problem.
I am using Win 2000 Advanced Server, SQL Server 2000 standard edn.
dotNET F/W 1.1
My table structure is
empid integer
empname varchar(30)
empname_chinese nvarchar(20)
From the asp.net page form field, If I input chinese characters, the chinese characters are displayed as ??? 40 ???(after 40 days)
Whats the problem.
I used same code as you posted above. ISO-8859-1
i am really disgusted with this. I am searching a lot in google. finally i got this article. But still didnt solve.
Can you please help me to solve my problem?
I've changed the in web.config also
still no use.
Any help is highly appreciated.
Rajani,
Montex Garment Sdn Bhd
|
|
|
|
 |
|
 |
first, you said "I input Chinese characters", do you mean input in text field and submit on asp.net page?
second, are you sure you are using a client support Chinese?
third, where you used ISO-8859-1? And ISO-8859-1 does not support Chinese.
I need your detail.
thanks.
Regards, Samuel
My blog - SamuelChen.net
|
|
|
|
 |
|
 |
Yes,
I want to input chinese characters in the textbox. Later i am displaying in datagrid. I am using Win 2000 server english version. I changed Regional Settings, language to Chinese Simplified also in control panel. So that I can input chinese characters. If i am using Access, i can able to store and display.
thanx for u r reply.
|
|
|
|
 |
|
 |
Hi
I think SQL SERVER 2000 can support utf8. So you may try setting all encoding as utf8.
Do you mean "using access" is using Access as the database in application or just using Access software to try input Chinese?
Maybe the key issue is client. Try not to store into database and display directly on next page.
for example. page1.aspx to input text. page2.aspx to response to display the inputed text. use utf8 in all page and web.config.
If page2.aspx displaying is ok. than check your SQL Server configure. Be sure SQL Server's encoding is setted as utf8.
Regards, Samuel
My blog - SamuelChen.net
|
|
|
|
 |
|
 |
Hello,
thanx for the reply.
I got the output. I just changed the insert query. Placed N preceded by the nvarchar column.
thanq
|
|
|
|
 |
|
 |
I'm working on a guestbook system that deals with a bunch of Chinese characters and the database is MySQL which is set to Latin1 by default.
Your post really saved me out!
Thank you!
http://www.cyclistlog.com/
|
|
|
|
 |
|
 |
Hi,
I found your article and I thing that you could help me.
I have an ASP.NET application which shows Cyrillic characters. I placed this in my web.config :
globalization
fileEncoding="windows-1251"
requestEncoding="windows-1251"
responseEncoding="windows-1251"
culture="bg-BG"
uiCulture="bg-BG"
Now I can read, but when I try to insert into the database some cyrillic characters, the result is ??????????. How could I fix this problem? Could you help me here?
|
|
|
|
 |
|
 |
hi viketo,
I can't be sure without environment provided.
Maybe your database does not support Cyrillic character encoding, I guess.
To fix it, try encoding Cyricllic into ISO-8859-1 before insert.
And encode data into Cyricllic encoding after select(load) from db.
Wish this can make helps.
Best regards
Samuel
www.alphatom.com
|
|
|
|
 |
|
 |
I have the same problem. I modified a bit of your code to convert my charset against the following web.config settings:
Before I call the SQL Insert statement, I tried the conversion as you suggest. But, it turns out to be "???" for the nvarchar field of SQL Server Database. Any idear ?
|
|
|
|
 |
|
 |
Is there any more information about the environment ?
|
|
|
|
 |
|
 |
I've just read your article and think its great and just about the ONLY article on the web that gives some information on the coding of character set. I have a real crisis now and was hoping you may be able to help. My project is in ASP.net using VB code behind. I need to generate an XML (SDF) file, which converts my Arabic text into ISO 8859-6 character set. I am using SQL database which stores my Arabic data in Arabic. I am creating this file using the StreamWriter. This file needs to sent elsewhere and they have requested that the Arabic text be converted into ISO 8859-6 character set. In your code , I tried changing the line to
Dim iso As Encoding = Encoding.GetEncoding("ISO8859-6"), but this gave me an error, statins "Not a recognised Character set format", so I changed it to
Dim iso As Encoding = Encoding.GetEncoding("ISO-8859-6"), but the output has no resemblence to the characters I see in the chart of ISO 8859-6.
PLEASE HELP...Many Thanks
|
|
|
|
 |
|
|
 |
|
 |
U saved my life
+
Question:
do U think it's possible that codepage is "lost" when POSTing data from ASP to an ASP.NET page ?
Best Regards - Yovav Gad
EMail: Dev@GadWorks.com
Web-Site: www.GadWorks.com
|
|
|
|
 |
|
 |
Hi, Yovav:
Thanks for your message and voting.
To your question "do U think it's possible that codepage is "lost" when POSTing data from ASP to an ASP.NET page ? ", I think it's not possible --- It's really truth .
When posting data from ASP to ASP.NET page, the codepage will automatically be changed into UTF-8.
Therefor, you'd better set your ASP.NET page's codepage/charset correctly.
Best regards
Samuel
|
|
|
|
 |
|
 |
Thanks for this info - I could not get it anywhere else... + How can I traslate this to ASP.NET (or at least define the CodePage) ? <%@CODEPAGE="1252"%> <% Session.CodePage=1252 ' IMPORTANT: syncronize with the server code page Response.Charset= "utf-8" ' IMPORTANT: make the server respond with correct charset %> Thanks again. My form is now POSTing correctly - thanks to you Best Regards - Yovav Gad EMail: Dev@GadWorks.com Web-Site: www.GadWorks.com
|
|
|
|
 |
|
 |
From your code, I found that you want dynamic codepage/charset for response. Is it?
For dynamic response in ASP.NET, put the follow code in Page_Load() event of .cs/.vb file :Session.CodePage=1252
Response.Charset="utf-8";
For static response, modify .aspx file like this:<%@ Page language="c#" Codebehind="AspNetPage1.aspx.cs" AutoEventWireup="false" Inherits="AspPostToAsp.Net.WebForm1" <code>codePage="1252"</code>%>
...
<code><META http-equiv="Content-Type" content="text/html; charset=utf-8">
If you used Session and Response Object to set codepage/charset, the defined value in .aspx file will be invalid.
Best regards
Samuel
|
|
|
|
 |
|
 |
I thought I should do it like this,
so the only solution for me is to use your great two conversion functions
great job ! - I'm sure that a lot of people don't have a clue how to deal with this problem...
Best Regards - Yovav Gad
EMail: Dev@GadWorks.com
Web-Site: www.GadWorks.com
|
|
|
|
 |
|
 |
Thanks, Yovav.
I'm very happy this article can solve your question.
Best regards
Samuel
|
|
|
|
 |