473,770 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot display Chinese data from database

Some chinese characters data (in Big5 encoding) is stored in database.
I tried to display the data in an aspx but the characters cannot display
correctly.
I tried anything I think is related:
- Setting the charset, codepage of the page
- changed the responseEncodin g in web.config to Big5
- hardcoded Response.Conten tEncoding to 950 (codepage of Big5)
- Change the file encoding to Big5 (in save option)
None of them work.

For the same data, it can displayed correctly in my classic asp.

Code (.NET)
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection connection = new
SqlConnection(C onfigurationSet tings.AppSettin gs["NewsDB"]);
SqlCommand command = new SqlCommand();
command.Connect ion = connection;
command.Command Text = "SELECT Newsid, StoryDate, StoryTime, Headline
FROM tblLatestHeader ";
command.Command Type = CommandType.Tex t;

SqlDataReader dataReader;
connection.Open ();
dataReader = command.Execute Reader();
string html = "";
while (dataReader.Rea d())
{
html += dataReader[3].ToString();
}
connection.Clos e();
Label1.Text = html;
Label2.Text = "ä½*好嗎" ; // this is chinese character which can display
correctly
}
Work in classic asp:
<%
Set connection = Server.CreateOb ject("ADODB.Con nection")
connection.Conn ectionString = "Provider=sqlol edb;Data Source=MyDB;Ini tial
Catalog=NewsDB; User Id=sa;Password= fakepwd;"
connection.open
Set rs = connection.exec ute("SELECT Newsid, StoryDate, StoryTime, Headline
FROM tblLatestHeader ")

While Not rs.eof
response.write rs("Headline") & "<br>"
rs.movenext
wend
%>

Nov 25 '05 #1
1 3118
Jason Chan wrote:
Some chinese characters data (in Big5 encoding) is stored in database.
I tried to display the data in an aspx but the characters cannot
display correctly.
I tried anything I think is related:
- Setting the charset, codepage of the page
The Codepage directive in ASP.NET 2.0 is the same as reponseEncoding in
web.config.
- changed the responseEncodin g in web.config to Big5
- hardcoded Response.Conten tEncoding to 950 (codepage of Big5)
And these are identical as well (the latter, like Codepage, works at
the page level though).
- Change the file encoding to Big5 (in save option)
That's only relevant at buildtime.
None of them work.

For the same data, it can displayed correctly in my classic asp.

Code (.NET)
private void Page_Load(objec t sender, System.EventArg s e)
{
SqlConnection connection = new
SqlConnection(C onfigurationSet tings.AppSettin gs["NewsDB"]);
SqlCommand command = new SqlCommand();
command.Connect ion = connection;
command.Command Text = "SELECT Newsid, StoryDate, StoryTime,
Headline FROM tblLatestHeader ";
command.Command Type = CommandType.Tex t;

SqlDataReader dataReader;
connection.Open ();
dataReader = command.Execute Reader();
string html = "";
while (dataReader.Rea d())
{
html += dataReader[3].ToString();
}
connection.Clos e();
Label1.Text = html;
Label2.Text = "ä½*好嗎" ; // this is chinese character which
can display correctly
}


If your hardcoded sample text is displayed correctly, there's quite
likely a problem with your ADO.NET provider. Are the correct characters
displayed when you debug your code right after retrieving strings from
the database?

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 25 '05 #2

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

Similar topics

4
4565
by: Scott Vercuski | last post by:
Hello All, I'm having a problem saving/displaying multiple lanaguages on an ASP page. Here's the general problem I'm having. I have an admin area of a website that allows a user to enter items in multiple languages. EX: NAME LANGUAGE Trade Show English 商业展览 Chinese
8
5481
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
1
7561
by: Daman | last post by:
Hi, I am currently facing difficulty displaying chinese, japanese, russian etc. characters. I am using VB 6 and ADO to query the DB2 Version 7.2 unicode database (UTF-8). The resultset that comes back contains garbage characters for Chinese, Russian etc languages. The english characters come back fine using ADO. It seems that DB2 assumes that my application is NOT Unicode compliant.
3
3566
by: Tom | last post by:
Hi, I built a aspx web page which the charset is UTF-8. I need to present the same Chinese content to both Traditional and Simplified Chinese. However, it shows error code for UTF-8, Big 5 or GB2312. All Chinese text cannot be displayed. I installed dot net framework 1.1 with traditional chinese language pack. The server OS is english windows 2000.
7
4313
by: c.verma | last post by:
I have a web application. There is a page which has a datagrid on it.The datagrid displays the data that comes from SAP. SAP sends the chinese characters to this grid. Before I display CHinese charactes, I have to use the following code to let it display on the web page: Public Function ToSCUnicode(ByVal str As String) As String Dim enc1252 As System.Text.Encoding = System.Text.Encoding.GetEncoding(1252) Dim arrByte_GBK As Byte() Dim...
1
2780
by: Jason Chan | last post by:
I have an asp to display data in database, the data is in big5 encoding (chinese characters) I haven't specify the codepage in the asp and placed the file into 2 machine. When I browse the file in NT machine the chinese characters can display correctly, but doesn't for the page in my winxp machine. Both OS is english version. Since the file is actually the same (by copy and paste), so any setting in the OS or IIS level cause the problem?...
12
3228
by: Steven Nagy | last post by:
Hi all, I have to do a website in chinese! Basically I just need to know how to output chinese characters. I am assuming its very easy, but have never done it before. I can however do simple things like changing the formats of currency and calendars and so on. I am guessing the answer is quite simple given; I assume Unicode would support all the chinese characters right? Ideally I'd like them to be able to enter their own content...
0
4104
by: kennymce | last post by:
Hi, I'm having trouble localizing my Oracle 9.2 / ASP web application for our Chinese-speaking users. My Oracle 9.2 Database has NLS_NCHAR_CHARACTERSET set to AL16UTF16. I've set up a test table thus: CREATE TABLE "TBL_TEST_CH"
3
1748
by: Raymond Chiu | last post by:
Dear All, I have posted my question as below. But no answers, hope it can found here. http://forums.microsoft.com/msdn/ShowPost.aspx?postid=3377176&isthread=true&siteid=1&authhash=e09bd5812ef06751e9618ca5e2acbf8709a7521a&ticks=633469349810029562
0
9619
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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
10260
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
10102
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
10038
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
9910
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...
1
7460
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
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
4007
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

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.