I wrote a function that replaces high ascii values with visually equivalent
values.


<!--- 
This attemps to replace the extended ascii characters with 
what could visually be considered the standard ascii equivalent. 
--->
<cffunction name="ReplaceExntededAscii" access="public" returntype="string"
output="no" hint="This attemps to replace the extended ascii characters with
what could visually be considered the standard ascii equivalent.">
<cfargument name="Text" type="string" required="yes" />

<!--- Set up local scope --->
<cfset var LOCAL = StructNew() />

<!--- Set up string buffer --->
<cfset LOCAL.NewText = CreateObject("java",
"java.lang.StringBuffer").Init("") />

<!--- Loop over characters to replace --->
<cfloop index="LOCAL.intIndex" from="1" to="#Len(ARGUMENTS.Text)#" step="1">
<!--- Get the current character --->
<cfset LOCAL.Character = Mid(ARGUMENTS.Text, LOCAL.intIndex, 1) />


<!--- Check to see if this character is extended --->
<cfif (Asc(LOCAL.Character) GTE 128)>
<!--- This is an extended character --->

<cfswitch expression="#Asc(LOCAL.Character)#"> 
<cfcase value="128">
<cfset LOCAL.NewText.Append("E") />
</cfcase>
<cfcase value="131">
<cfset LOCAL.NewText.Append("f") />
</cfcase>
<cfcase value="134">
<cfset LOCAL.NewText.Append("t") />
</cfcase>
<cfcase value="138">
<cfset LOCAL.NewText.Append("S") />
</cfcase>
<cfcase value="140">
<cfset LOCAL.NewText.Append("C") />
</cfcase>
<cfcase value="142">
<cfset LOCAL.NewText.Append("Z") />
</cfcase>
<cfcase value="154">
<cfset LOCAL.NewText.Append("s") />
</cfcase>
<cfcase value="156">
<cfset LOCAL.NewText.Append("c") />
</cfcase>
<cfcase value="158">
<cfset LOCAL.NewText.Append("z") />
</cfcase>
<cfcase value="159">
<cfset LOCAL.NewText.Append("Y") />
</cfcase>
<cfcase value="161">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="162">
<cfset LOCAL.NewText.Append("c") />
</cfcase>
<cfcase value="163">
<cfset LOCAL.NewText.Append("L") />
</cfcase>
<cfcase value="165">
<cfset LOCAL.NewText.Append("Y") />
</cfcase>
<cfcase value="169">
<cfset LOCAL.NewText.Append("c") />
</cfcase>
<cfcase value="170">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="192">
<cfset LOCAL.NewText.Append("A") />
</cfcase>
<cfcase value="193">
<cfset LOCAL.NewText.Append("A") />
</cfcase>
<cfcase value="194">
<cfset LOCAL.NewText.Append("A") />
</cfcase>
<cfcase value="195">
<cfset LOCAL.NewText.Append("A") />
</cfcase>
<cfcase value="196">
<cfset LOCAL.NewText.Append("A") />
</cfcase>
<cfcase value="197">
<cfset LOCAL.NewText.Append("A") />
</cfcase>
<cfcase value="198">
<cfset LOCAL.NewText.Append("A") />
</cfcase>
<cfcase value="199">
<cfset LOCAL.NewText.Append("C") />
</cfcase>
<cfcase value="200">
<cfset LOCAL.NewText.Append("E") />
</cfcase>
<cfcase value="201">
<cfset LOCAL.NewText.Append("E") />
</cfcase>
<cfcase value="202">
<cfset LOCAL.NewText.Append("E") />
</cfcase>
<cfcase value="203">
<cfset LOCAL.NewText.Append("E") />
</cfcase>
<cfcase value="204">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="205">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="206">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="207">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="208">
<cfset LOCAL.NewText.Append("D") />
</cfcase>
<cfcase value="209">
<cfset LOCAL.NewText.Append("N") />
</cfcase>
<cfcase value="210">
<cfset LOCAL.NewText.Append("O") />
</cfcase>
<cfcase value="211">
<cfset LOCAL.NewText.Append("O") />
</cfcase>
<cfcase value="212">
<cfset LOCAL.NewText.Append("O") />
</cfcase>
<cfcase value="213">
<cfset LOCAL.NewText.Append("O") />
</cfcase>
<cfcase value="214">
<cfset LOCAL.NewText.Append("O") />
</cfcase>
<cfcase value="215">
<cfset LOCAL.NewText.Append("x") />
</cfcase>
<cfcase value="216">
<cfset LOCAL.NewText.Append("O") />
</cfcase>
<cfcase value="217">
<cfset LOCAL.NewText.Append("U") />
</cfcase>
<cfcase value="218">
<cfset LOCAL.NewText.Append("U") />
</cfcase>
<cfcase value="219">
<cfset LOCAL.NewText.Append("U") />
</cfcase>
<cfcase value="220">
<cfset LOCAL.NewText.Append("U") />
</cfcase>
<cfcase value="221">
<cfset LOCAL.NewText.Append("Y") />
</cfcase>
<cfcase value="223">
<cfset LOCAL.NewText.Append("B") />
</cfcase>
<cfcase value="224">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="225">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="226">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="227">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="228">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="229">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="230">
<cfset LOCAL.NewText.Append("a") />
</cfcase>
<cfcase value="231">
<cfset LOCAL.NewText.Append("c") />
</cfcase>
<cfcase value="232">
<cfset LOCAL.NewText.Append("e") />
</cfcase>
<cfcase value="233">
<cfset LOCAL.NewText.Append("e") />
</cfcase>
<cfcase value="234">
<cfset LOCAL.NewText.Append("e") />
</cfcase>
<cfcase value="235">
<cfset LOCAL.NewText.Append("e") />
</cfcase>
<cfcase value="236">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="237">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="238">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="239">
<cfset LOCAL.NewText.Append("i") />
</cfcase>
<cfcase value="240">
<cfset LOCAL.NewText.Append("o") />
</cfcase>
<cfcase value="241">
<cfset LOCAL.NewText.Append("n") />
</cfcase>
<cfcase value="242">
<cfset LOCAL.NewText.Append("o") />
</cfcase>
<cfcase value="243">
<cfset LOCAL.NewText.Append("o") />
</cfcase>
<cfcase value="244">
<cfset LOCAL.NewText.Append("o") />
</cfcase>
<cfcase value="245">
<cfset LOCAL.NewText.Append("o") />
</cfcase>
<cfcase value="246">
<cfset LOCAL.NewText.Append("o") />
</cfcase>
<cfcase value="248">
<cfset LOCAL.NewText.Append("o") />
</cfcase>
<cfcase value="249">
<cfset LOCAL.NewText.Append("u") />
</cfcase>
<cfcase value="250">
<cfset LOCAL.NewText.Append("u") />
</cfcase>
<cfcase value="251">
<cfset LOCAL.NewText.Append("u") />
</cfcase>
<cfcase value="252">
<cfset LOCAL.NewText.Append("u") />
</cfcase>
<cfcase value="253">
<cfset LOCAL.NewText.Append("y") />
</cfcase>
<cfcase value="255">
<cfset LOCAL.NewText.Append("y") />
</cfcase>
</cfswitch>

<cfelse>
<!--- This is a standard company --->
<cfset LOCAL.NewText.Append(LOCAL.Character) />
</cfif>

</cfloop>

<!--- Return the equivalent value --->
<cfreturn LOCAL.NewText.ToString() />
</cffunction>   


Hope that helps
-ben nadel



-----Original Message-----
From: Kevin Bridges [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 09, 2005 9:44 AM
To: CF-Talk
Subject: Re: Strip ascii 128 and above

Ok I answered my own question:

for (i = 128; i LTE 159; i = i + 1)
text = Replace(text, Chr(i), "", "All");



Kevin Bridges wrote:

>Is there a simple way to strip out all characters above ascii 127 from a 
>string? 
>  
>




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:217848
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to