Skip to main content
Inspiring
March 9, 2007
Question

convert utf-8 to iso-8859-1

  • March 9, 2007
  • 12 replies
  • 3031 views
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)
This topic has been closed for replies.

12 replies

Inspiring
March 9, 2007
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é
Inspiring
March 9, 2007
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é
Inspiring
March 9, 2007
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.
Inspiring
March 9, 2007
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.
Inspiring
March 9, 2007
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é
Inspiring
March 9, 2007
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?
Inspiring
March 9, 2007
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?
BKBK
Community Expert
Community Expert
March 9, 2007
Couldn't you just do everything in utf-8?

Inspiring
March 9, 2007
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
Inspiring
March 9, 2007
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