1

I have already created some fields in a PDF form. Then I create a submit button for submitting those data with html format to an asp. Those data can be successfully retrieved by Request.Form() except Chinese character.

If the data can be successfully retrieved, that will be shown in my asp.

When I submit the field (Name) with Chinese character

Response.write(Request.Form("Name")) 'the value of field in PDF is "測試"

The page show nothing.

If the value of the the field (Name) is not Chinese character

Response.write(Request.Form("Name")) 'the value of Request.Form("Name") is "Mary"

The page shows "Mary"

I have already add the code page and charset in my asp

<%@ LANGUAGE=VBScript CODEPAGE=65001 %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Next, I try to test out if the Chinese character cannot be retrieved or cannot be written.

response.write("中文測試")

"中文測試" can be successfully shown

When I change the code page and charset to 1252 and ANSI

<%@ LANGUAGE=VBScript CODEPAGE=1252 %>
<meta http-equiv="Content-Type" content="text/html; charset=ANSI">

try again

Response.write(Request.Form("Name")) 'the value of field in PDF is "測試"

the result shows ‘ªŽŽ

I think that the problem is fail to retrieve data from PDF submission. How can I successfully get the data with Chinese character? or something I missed out?

The asp file: click to view the image

5AM75U1
  • 11
  • 2
  • It's not just a case of changing the `CODEPAGE`, the ASP page has to be saved using the correct encoding. For example if you set `CODEPAGE = 65001` *(UTF-8)* but the ASP page is saved as Windows 1252 you will get an encoding mismatch, both how IIS is told to process the ASP page and how it the page is saved must match or you will get weird results like this. – user692942 Aug 16 '18 at 06:00
  • @Lankymart After adding `Response.CodePage = 65001` and `Response.CharSet = "utf-8" ` The result is still **‘ªŽŽ**. Actually I have a database to store this field and the value is same **‘ªŽŽ**. – 5AM75U1 Aug 16 '18 at 06:25
  • You are missing the point what encoding is the ASP page saved using? They have to match or you will get an encoding mismatch. Only point to [that answer](https://stackoverflow.com/a/21914278/692942) because it explains the steps to go through, the fact its talking about a database is irrelevant the steps for handling encoding correctly in Classic ASP are always the same. – user692942 Aug 16 '18 at 06:27
  • @Lankymart Sorry,I make it confuse. On the top in my asp, I have added `<%@ LANGUAGE=VBScript CODEPAGE= 65001%>` `<% Response.CharSet = "utf-8"` `<%Response.CodePage = 65001%>` is it match the asp saved? But the value is empty. Therefore, I try `<%@ LANGUAGE=VBScript CODEPAGE= 1252%>` `<% Response.CharSet = "ANSI"` `<%Response.CodePage = 1252%>` The value is **‘ªŽŽ** and it is not the result that I want. – 5AM75U1 Aug 16 '18 at 06:49
  • When you edit the ASP page and it comes to save it is it saved *(physically to the hard drive)* with UTF-8 encoding? – user692942 Aug 16 '18 at 06:59
  • I use note++ to save my asp with utf-8 encoding. But the value is still empty. May be the PDF form submitted to my asp cannot be encoded to utf-8? I have tried `Response.write(Request.Form("Name"))` and checked the database (the value of field "Name") is empty ) – 5AM75U1 Aug 16 '18 at 07:27
  • In which case the PDF submission is not using UTF-8 encoding, you will need to determine what encoding the PDF submission is using and alter the ASP page accordingly. – user692942 Aug 16 '18 at 07:48
  • 1
    You have encountered a problem that is caused by a flaw in ISO 32000-1. I fixed this flaw in ISO 32000-2. Not that many tools already support ISO 32000-2, hence you have to work around the problem. You can do so by adapting your form so that it isn't submitted using an actual submit button, but by using an ordinary button that triggers the Adobe JavaScript `submitForm()` method using the right encoding as parameter. Unfortunately, this method will only work in PDF viewers that support Adobe JavaScript. – Bruno Lowagie Aug 16 '18 at 08:11
  • 1
    @Bruno Lowagie I will use the submit button to trigger the ‘submitForm’ method. It should solve my problem. Thank you so much. – 5AM75U1 Aug 16 '18 at 11:14

0 Answers0