Multi Language Storage and Display

S

Scott Vercuski

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
Торговая
выставка Russian

When I store and display the chinese and Russian text I'm using an
update statement as follows.

UPDATE TABLE SET NAME =
N'Торговая
выставка' WHERE LANG =
'RU'

When I read that text out of the database and try to display it, it
just comes up as garbage. If I change my browser encoding to Unicode
(UTF-8) it still comes up as garbage. My question is, how can I get
multiple languages to display on one page?

Thanks in advance for any assistance.
Scott Vercuski
 
A

Arnold Shore

I'm using the familiar meta: <META HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=UTF-8">, and storing/pulling text into/from an
Access db. I haven't seen the need to use the entities you show.

AS
 
A

Arnold Shore

I should have mentioned that I'm doing UTF-8 for Russian/Cyrillic, Arabic,
Hebrew, and the CJK languages as well as English and the Europeans. FWIW.

AS
 
R

Ross McKay

[Follow-ups trimmed to microsoft.public.data.ado]

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
Торговая
выставка Russian

When I store and display the chinese and Russian text I'm using an
update statement as follows.

UPDATE TABLE SET NAME =
N'Торговая
выставка' WHERE LANG =
'RU'

When I read that text out of the database and try to display it, it
just comes up as garbage. If I change my browser encoding to Unicode
(UTF-8) it still comes up as garbage. My question is, how can I get
multiple languages to display on one page?

Firstly, I'm assuming you have your character string columns in your
database as type NVARCHAR, so that they can accommodate Unicode strings.

Next, you should be running on Windows 2000 or XP, so that you are using
IIS 5.0 or higher. You can do this on NT4 with IIS 4.0, but there are
more hoops to jump - it's just not worth it.

When retrieving date from the database to display on the ASP page, you
need to set the CodePage and the CharSet, as follows (example is UTF-8):

<%@ language="vbscript" codepage=65001 %>
<% Response.CharSet = "UTF-8" %>

This allows data pulled from the database to be correctly encoded as
UTF-8 on output. Alternatively, if you use Server.HTMLEncode it will
give you HTML encoded versions, like in you example text above (but of
course, your page download size will increase).

For saving your data back to the database, which I presume is SQL Server
given the list of groups you cross-posted to, write a stored procedure
to do the work and use the Parameters collection of the ADO Command
object to set the values. Specify adVarWChar as data type.

Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = db_conn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "your_stored_proc"
Set params = cmd.Parameters

params.Append cmd.CreateParameter(, adVarWChar, adParamInput, _
20, fldTitle)

params.Append cmd.CreateParameter(, adVarWChar, adParamInput, _
60, fldFirstName)

params.Append cmd.CreateParameter(, adVarWChar, adParamInput, _
60, fldLastName)

params.Append cmd.CreateParameter(, adDate, adParamInput, _
, fldReturn_Date)

cmd.Execute , , adCmdStoredProc + adExecuteNoRecords

Works for me.

regards,
Ross.
 
J

Jerry III

If you're storing the data as HTML entities (and you are) you don't need the
data type to be a Unicode string as entities will only have standard ASCII
characters. Second, take a look at the page source (i.e. the HTML you're
generating). If that looks ok (there actually is
商业展览 for the Chinese version) then you need to
set your browser to use a font that actually has the characters you're
trying to display. It does not matter what the encoding is since your output
is going to be only 7-bit ASCII.

To make it short - the first step is to check the page source and see what's
in there. Let us know.

Jerry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top