1

I have a site that displays multiple languages. The site is Classic ASP (VBScript) driven and depending on the users settings (language preferences) will display the HTML in the desired language. The language file is a simple ASP file using a set of if statements to equate a variable to the desired language.

For example:

if language = "Spanish" then
    day_name = "lunes"
elseif language = "Chinese" then
    day_name = "星期一"
else
    day_name = "Monday"
end if

Then the ASP page would include the result:

Today is <%=day_name%>

After many hours of research I have added the following to the header of the ASP pages:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Option Explicit%>
<%
Response.CodePage = 65001    
Response.CharSet = "utf-8"
%>
<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
%>

The above works fine for English and Chinese, however with Spanish and other languages strange characters appear like "�"

I have also attempted to save the ASP language file as UTF-8, UTF-8-BOM and ANSI (using Notepad++). The characters themselves also change in Notepad++ depending on what option I choose, never all having the correct encoding. Not sure if the solution is to create multiple files, one for each language and each file encoded accordingly (which is technically possible but a significant amount of work to do and maintain).

I can't seem to find the correct balance to suit all languages and any guidance would be appreciated.

Thank you.

  • 1
    You have an encoding mismatch, make sure that the Spanish characters are UTF-8 and not ANSI eqivalents. See https://stackoverflow.com/a/21914278/692942 – user692942 May 13 '18 at 23:32
  • 1
    Thank you. Finally solved. The post that you shared triggered an idea. I converted the file to ANSI so that the Spanish words were legible. Then cut the Spanish words out, converted the file to UTF-8 so that the Chinese words were legible and then pasted the Spanish words back in. All working now. Much appreciated! –  May 14 '18 at 13:05

0 Answers0