...

View Full Version : ASP: Working with ajax



BarrMan
09-13-2007, 10:02 AM
Hey. I've made a script that pulls information from my database to a textbox but it's not in english and it shows the letters instead of in their original form as question marks. (IE: Hello = ????).
When I opened my database to see if the information is correct there I saw that it's ok but when it draws it from the database into the textarea I get this funny looking text.
Here's my insertion code:

<%@ Language=VBScript %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html dir="rtl">
<head>
<title>
טאודור בר - מערכת ניהול
</title>
<meta http-equiv="content-type" content="text/html; charset=windows-1255" />
</head>
<body>
<%
Function strFormat(str)
If IsEmpty(str) or IsNull(str) Then Exit Function
Str = Replace(str,"<","&lt;")
Str = Replace(str,">","&gt;")
Str = Replace(str,"'","&#39;")
Str = Replace(str,"""","&quot;")
Str = Replace(str,chr(13),"<br />")
Str = Replace(str,"'","&#39;")
strFormat = str
End Function
Dim Lang
Dim Conn
Dim Rs
Dim SQL
Lang = Request.Form("language")
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open = "PROVIDER=Microsoft.Jet.Oledb.4.0; Data Source='" & Server.MapPath("../db.mdb") & "'"
SQL = "UPDATE contents SET content = '" & StrFormat(Request.Form("txt")) & "' WHERE page='index' AND lang='" & Lang & "'"
Conn.Execute SQL
Conn.Close
Set Conn = Nothing
Response.Redirect Request.Form("url")
%>
</body>
</html>

Daemonspyre
09-13-2007, 03:22 PM
Your title is a little deceiving, as this is not an AJAX problem, but a text encoding problem.

So, here's a question --

You say that when you look at the data in the database that it's OK, but when you retrieve it INTO a textbox, there is an encoding issue.

Have you tried just doing a simple response.write or putting it into a DIV (or a PRE) to see if it returns correctly?

BarrMan
09-14-2007, 03:18 PM
Your title is a little deceiving, as this is not an AJAX problem, but a text encoding problem.

So, here's a question --

You say that when you look at the data in the database that it's OK, but when you retrieve it INTO a textbox, there is an encoding issue.

Have you tried just doing a simple response.write or putting it into a DIV (or a PRE) to see if it returns correctly?
Hey. Sorry for the misleading title. Thought it's an AJAX problem.
When I try to view it on a div the same error occurs.

Daemonspyre
09-14-2007, 04:19 PM
There have been a few posts as of late with regards to Hebrew ( Semitic ) alphabet.

Make sure that you use a couple of little tricks:

1) Make sure your page encoding is UTF-8. This is done with a META tag

<meta http-equiv="content-type" content="text/html; charset=utf-8" />

2) Make sure your Session.LCID = 1037 (numeric location code for Hebrew).

More information on Locale IDs (LCID) can be found here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vsmscLCID.asp).

Let me know if this works for you.

BarrMan
09-14-2007, 04:50 PM
Not yet solved.
Hey.
Thanks for the help!
I thought windows-1255 is the hebrew charset and that's what I used in my page but now I've tried yours and it still doesn't work.
I've also added the Session.LCID = 1037 at the beginning of the page and still I get the same unidentified letters error.

When I checked my ajax.asp document it showed the letters alright too.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum