• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

decode UTF-8 to ISO-8859-1

Contributor ,
Nov 23, 2009 Nov 23, 2009

Copy link to clipboard

Copied

I am using the Google Maps API, it return in utf-8,

so for some countries, caracters are wrong,

My server is ISO-8859-1

So, how to convert the result from utf-8 to iso-8859-1 ?

I tried :

<cfprocessingdirective pageEncoding="UTF-8">
<cfcontent type="text/html; charset=UTF-8">
<cfset setEncoding("URL", "UTF-8")>
<cfset setEncoding("FORM", "UTF-8")>

and

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

No change. always the wrong caracters,

Thanks for any help with this mess.

Pierre.

TOPICS
Advanced techniques

Views

3.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 23, 2009 Nov 23, 2009

Copy link to clipboard

Copied

But your ColdFusion is not necessarily using the same charset as your server.

Which version of CF are you using? If you are using CF 5 or older, forget it. If later, it should work out of the box if you use the appropriate charset attributes everywhere. Can you explain a bit more about the processing code?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 23, 2009 Nov 23, 2009

Copy link to clipboard

Copied

Hi!

Try this trick:

<cfsript>

s="your_text";
chr_current="your_current_charset";
chr_new="your_new_charset";


c=createobject("java", "java.lang.String").init(s);
convstring=createobject("java", "java.lang.String").init(c.getbytes(chr_current),chr_new).tostring();
</cfscript>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 24, 2009 Nov 24, 2009

Copy link to clipboard

Copied

I am using CF v7.

My server and CF are ISO-8859-1.

But I am using Google Maps API , which returns country names in UTF-8.

I tried the Google Maps directives, with adding parameter eo=ISO-8859-1 in the Google Key <script>,

same result.

Then  I have to convert to ISO-8859-1 , at least in that page for country names.

(I have a specific problem with Thailande, Google Maps returns :  Tha๏lande

and in the data base it writes : tha&#3663 ;lande   (an Access database)

I answer to injun [576871]  ,

Diificult to insert that code, because I am in a JavaScript code already.

So it will not accept <cfscript> again inside ? I will try.

Thanks for any help.

Pierre.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 24, 2009 Nov 24, 2009

Copy link to clipboard

Copied

Thanks, I will try at end of day,

I have a meeting right now.

Regard, Pierre.

======================================

Pl-Art - Pierre LARDE

http://www.pl-arts.com

Email : pierre@pl-arts.com

Tel : 04 93 60 48 91

Auberge de la Clue, 06850, St Auban

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 24, 2009 Nov 24, 2009

Copy link to clipboard

Copied

Hi,

I tried it before the insert Query,

But I get the same value :

Before : Tha๏lande

After : Tha๏lande

here is the code :

What do you think of ?

Thanks for all.

Pierre.

======================================

Pl-Art - Pierre LARDE

http://www.pl-arts.com

Email : pierre@pl-arts.com

Tel : 04 93 60 48 91

Auberge de la Clue, 06850, St Auban

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 24, 2009 Nov 24, 2009

Copy link to clipboard

Copied

LATEST

I answered by mail, and the code has not appeared

.

here is the code used :

<cfoutput>
before : #form.pays#<br>
<cfscript>
s="#form.pays#";
chr_current="utf-8";
chr_new="ISO-8859-1";
c=createobject("java", "java.lang.String").init(s); convstring=createobject("java", "java.lang.String").init(c.getbytes(chr_current),chr_new).tostring();
</cfscript>
after : #convstring#<br>
</cfoutput>

Thanks for any help.

Pierre.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation