#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0

    Question Parsing Korean characters through ASP


    Hello all,

    I'm using ASP to grab data from an excel file stored on the server and display it on a page. The problem I'm having is that Korean characters are not showing up. Instead, I'm getting question marks.

    Here's my code.

    Code:
    <html>
    <head>
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="949"%>
    </head>
    <body>
    
    <%
    
    Response.CodePage = 65001
     
    Dim objConn, objRS, strSQL
    Dim x
    
    Set objConn = Server.CreateObject("ADODB.Connection")
    objConn.Open "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=0; HDR=NO; "&_
    	"Excel 8.0; DBQ=" & Server.MapPath("test-input.xls") & "; "
    
    strSQL = "SELECT * FROM A1:Q10000"
    Set objRS=objConn.Execute(strSQL)
    Response.Write("<table border=""1"">")
    Response.Write("<tr>")
    For x=0 To objRS.Fields.Count-1
       Response.Write("<th>" & objRS.Fields(x).Name & "</th>")
    Next
    Response.Write("</tr>")
    Do Until objRS.EOF
    	Response.Write("<tr>")
    	For x=0 To objRS.Fields.Count-1
    		Response.Write("<td>" & objRS.Fields(x).Value & "</td>")
    	Next
    	Response.Write("</tr>")
    	objRS.MoveNext
    Loop
    objRS.Close
    Response.Write("</table>")
    objConn.Close
    Set objRS=Nothing
    Set objConn=Nothing
    %>
    </body>
    </html>
    The funny thing is...
    Code:
    Response.Write("<th>" & objRS.Fields(x).Name & "</th>")
    displays the Korean characters just fine... but
    Code:
    Response.Write("<td>" & objRS.Fields(x).Value & "</td>")
    gives me the ???'s.

    Can anyone shed any light on this, and on what I should do to fix it?

    Thanks,

    Tam.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,424
    Rep Power
    4539
    I don't do multi-lingual coding, but my guess from your description is that the data is being inserted in your db with the wrong encoding, which is why the column names are correct but not the value data.

    Just a guess though.
    ======
    Doug G
    ======
    The man who doesn't read good books has no advantage over the man who can't read them.
    --Mark Twain
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0
    Thanks for the input, but the data is coming direct from the excel spreadsheet, which has the Korean characters in it... I have a local copy on my machine and the Korean characters are fine there...

    I did have a thought though... it could be that my host doesn't have the Korean language pack on their excel install... and if that's the case, I'm humped.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    5
    Rep Power
    0
    Bump.

    I have still had no success with this problem. No matter what I do I cannot get the Korean characters in my excel spreadsheet to survive into the recordset.

    I've determined it's not the server's problem. That's because Response.Write(objRS.Fields(x).Name) displays the Korean characters in the 1st row of my spreadsheet.

    It's only Response.Write(objRS.Fields(x).Name) that displays '???' instead of the characters.

    I have saved the excel spreadsheet in UTF-8 format, I have the codepage set to '65001' in the <@ %> at the top and the charset set as "utf-8". My asp page has also been saved in utf-8 format, and nothing makes a difference. If anyone could please, please tell me how to solve this weird problem, I would be forever grateful, I'm tearing my hair out here.

IMN logo majestic logo threadwatch logo seochat tools logo