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

Replacing Special Characters when writing to a file

New Here ,
Apr 09, 2010 Apr 09, 2010

I am using the following to replace Muñoz  (the ñ with null) .  It should output as Muoz.

This should be simple but it is not working.  209 and 241 represent the upper and lower case ñ.

This statement is in a CFFILE.  I am generating the file but the ñ is still there.

replace(LGL_NM,chr(209)&chr(241),'3','all')

I also tried the following without success:

<cfset x = ReplaceNoCase(#Object_query.LGL_NM#,"#chr(209)#", " ", "all")>
<cfset LGL_NM = ReplaceNoCase(x,"#chr(241)#", " ", "all")>

Please Help.

Thanks!

Bill

1.0K
Translate
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

correct answers 1 Correct answer

Community Expert , Apr 11, 2010 Apr 11, 2010

<!--- sets the encoding to UTF-8 --->

<cfprocessingdirective pageencoding="utf-8">
<cfset testString="muñaÑoz">

<!--- Replace any character match in the regular expression [ñÑ] with a blank string--->
<cfoutput>#REReplaceNoCase(testString, "[#chr(209)##chr(241)#]", "", "all")#</cfoutput>

Translate
Contributor ,
Apr 09, 2010 Apr 09, 2010

When I try what you pasted, I get "Mu oz" in the file.  The n is missing.  Not sure why it's not working for you.  Maybe a charset thing?  I'm using iso-8859-1

Translate
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
New Here ,
Apr 09, 2010 Apr 09, 2010

Thanks for the response Paul.

Where is the character set defined?  How do I know what I am using?

Thanks again.

Bill

Translate
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 ,
Apr 10, 2010 Apr 10, 2010

I mean on the page itself, in the meta tag.  Not sure if it's what's causing the difference though.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Translate
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 ,
Apr 11, 2010 Apr 11, 2010

<!--- sets the encoding to UTF-8 --->

<cfprocessingdirective pageencoding="utf-8">
<cfset testString="muñaÑoz">

<!--- Replace any character match in the regular expression [ñÑ] with a blank string--->
<cfoutput>#REReplaceNoCase(testString, "[#chr(209)##chr(241)#]", "", "all")#</cfoutput>

Translate
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
New Here ,
Apr 11, 2010 Apr 11, 2010

Thank You!  That worked!

Bill

Translate
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 ,
Apr 11, 2010 Apr 11, 2010
LATEST

OK. Good luck.

Translate
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