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

convert utf-8 to iso-8859-1

LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

Hello,
sorry for my very bad english

i use httpxmlrequest to answer a database and show resultin a div
the string means utf-8 encoded by my javascript fonction and, of course,
no result are found in the database.
How can i convert the string to iso-8859-1 before request the database ?

Thank if you have an idea

JiBé (France)
TOPICS
Advanced techniques

Views

2.8K

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
Community Expert ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

What happens when you put

<cfscript>
SetEncoding("url", "iso-8859-1");
</cfscript>
<cfprocessingdirective pageencoding="iso-8859-1">

at the top of the Coldfusion page?


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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied


I do that in the application.cfm page
I just have this problem with httpxmlrequest
So i want to convert my string before use it in the SQL

JiBé
>
> <cfscript>
> SetEncoding("url", "iso-8859-1");
> </cfscript>
> <cfprocessingdirective pageencoding="iso-8859-1">
>
> at the top of the Coldfusion page?
>
>
>

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

Jib wrote:
> How can i convert the string to iso-8859-1 before request the database ?

well you might not be able to as iso-8859-1 is a subset of unicode. what
languages are you dealing with? are you sure they will fit into iso-8859-1? i
guess maybe have a look at this:
http://www.phillipholmes.com/?p=46

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

PaulH **AdobeCommunityExpert** a écrit :
> Jib wrote:
>> How can i convert the string to iso-8859-1 before request the database ?

Maybe it is more simple with an example :
http://habitat-developpement.tm.p15.siteinternet.com/test/
If you seach energie it works...
If oyu search énergie there is no result because it search "énergie"...

Jibé
> well you might not be able to as iso-8859-1 is a subset of unicode. what
> languages are you dealing with? are you sure they will fit into
> iso-8859-1? i guess maybe have a look at this:
> http://www.phillipholmes.com/?p=46

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
Community Expert ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

Couldn't you just do everything in utf-8?

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

Jibé wrote:
> Maybe it is more simple with an example :
> http://habitat-developpement.tm.p15.siteinternet.com/test/

show the code for that. it seems your encoding isn't the same back-to-front. is
it getting to the db ok? what db? what encoding in the db?

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

PaulH **AdobeCommunityExpert** a écrit :
I work with a MS SQL server database encoding in iso-8859-1
The code :
<cfif len(form.id) GT 2>
<cfquery name="l_fichier" datasource="#bdd#">
select *
from fichier
where titre like '%#form.id#%'
or contenu like '%#form.id#%'
order by rubrique
</cfquery>
<cfelse>
<cfset l_fichier.recordcount = 0>
</cfif>

<cfoutput>
<b> Résultat de votre recherche #form.id#</b>
<div id="trans">
<cfif l_fichier.recordcount EQ 0>
<div id="resultat">Aucun fichier ne correspond à votre demande</div>
<cfelse>
<div id="x_contenu">
<cfloop query="l_fichier">
#lsdateformat(date_modif,'dd/mm/yyy')# - #titre#<br/>
</cfloop>
</div>
</cfif>
</div>
</cfoutput>

JiBé
>
> show the code for that. it seems your encoding isn't the same
> back-to-front. is it getting to the db ok? what db? what encoding in the
> db?

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

BKBK a écrit :
> Couldn't you just do everything in utf-8?
>
>
I'm not the owner of the database... I just use it.

JiBé

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

Jibé wrote:
> PaulH **AdobeCommunityExpert** a écrit :
> I work with a MS SQL server database encoding in iso-8859-1

data stored in plain text,char,varchar datatypes (ie not "N")? using the ODBC or
JDBC (it would be listed as ms sql server in the db drivers list) driver?

> The code :

you're not following good i18n practices. while my preference is for unicode
("just use unicode" has been my motto for years), if you're really only ever
going to use french & never need the euro symbol then i guess iso-8859-1
(latin-1) is fine.

add to top of all your cf pages:
<cfprocessingdirective pageencoding="iso-8859-1">

in your application.cfm (or it's equivalent) add:
<cfset setEncoding("form","iso-8859-1")>
<cfset setEncoding("url","iso-8859-1")>
<cfcontent type="text/html; charset=iso-8859-1">

if you think you might need other languages, including the euro symbol, then you
should consider unicode. change your text columsn to "N" type (nText, nChar,
nVarChar) & swap the latin-1 encodings in the tags above to utf-8.

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

Jibé wrote:
> PaulH **AdobeCommunityExpert** a écrit :
> I work with a MS SQL server database encoding in iso-8859-1

data stored in plain text,char,varchar datatypes (ie not "N")? using the ODBC or
JDBC (it would be listed as ms sql server in the db drivers list) driver?

> The code :

you're not following good i18n practices. while my preference is for unicode
("just use unicode" has been my motto for years), if you're really only ever
going to use french & never need the euro symbol then i guess iso-8859-1
(latin-1) is fine.

add to top of all your cf pages:
<cfprocessingdirective pageencoding="iso-8859-1">

in your application.cfm (or it's equivalent) add:
<cfset setEncoding("form","iso-8859-1")>
<cfset setEncoding("url","iso-8859-1")>
<cfcontent type="text/html; charset=iso-8859-1">

if you think you might need other languages, including the euro symbol, then you
should consider unicode. change your text columsn to "N" type (nText, nChar,
nVarChar) & swap the latin-1 encodings in the tags above to utf-8.

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

PaulH **AdobeCommunityExpert** a écrit :
> Jibé wrote:
>> PaulH **AdobeCommunityExpert** a écrit :
>> I work with a MS SQL server database encoding in iso-8859-1
>
> data stored in plain text,char,varchar datatypes (ie not "N")?
datatype of "titre" is varchar(250) and "contenu" is text
using the
> ODBC or JDBC (it would be listed as ms sql server in the db drivers
> list) driver?
I think it's jdbc driver (case of my test computer)


>
>> The code :
>
> you're not following good i18n practices. while my preference is for
> unicode ("just use unicode" has been my motto for years), if you're
> really only ever going to use french & never need the euro symbol then i
> guess iso-8859-1 (latin-1) is fine.

Here is a part of the content of my application.cfm
<cfprocessingdirective pageencoding="iso-8859-1">
<cfcontent type="text/html; charset=iso-8859-1">
<cfset setEncoding("URL", "iso-8859-1")>
<cfset setEncoding("Form", "iso-8859-1")>

>
> if you think you might need other languages, including the euro symbol,
> then you should consider unicode. change your text columsn to "N" type
> (nText, nChar, nVarChar) & swap the latin-1 encodings in the tags above
> to utf-8.
I'm going to test that....

JiBé

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
LEGEND ,
Mar 09, 2007 Mar 09, 2007

Copy link to clipboard

Copied

LATEST
OK, if i add
<cfset setEncoding("Form", "utf-8")> at the top of my
x_fichier_cherche.cfm it works fine

Thank's a lot for your help.

JiBé

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