Hello,

I have an odd error with a piece of code I'm migrating from CF5 to
MX6.1.  It is a simple switch statement that takes Hex7 values as a
string and spits out the ascii equivilent as a string.

Problem is, it is reading hex value '00' and '0A' as the same thing,
and returns a duplicate value error for 0.0.  I've tried chr codes,
changing it to IF statements, and more.  I was hoping an expert could
look at it and give me a hint to a fix.  Below is a small snippet of
the overall code.  Thanks.

<cfscript>
function Hex7toStr(Char){
        switch (Char)                      
        {                                
        case "00":                   
                newchar = "NUL";       
                break;                        
        case "0A":
                newchar = "LF";
                break;          
        case "30":
                newchar = "0";
                break;          
        case "41":
                newchar = "A";                                             
                break;          
        case "EB":
                newchar = "a";
                break;          
        }
        return Trim(newchar);
}


</cfscript>
<cfset hexChar1 = "00">
<cfset hexChar2 = "0A">
<cfset hexChar3 = "30">
<cfset hexChar4 = "41">
<cfset hexChar5 = "E1">
<CFSET hexStr1 = #Hex7toStr(hexChar1)#>
<CFSET hexStr2 = #Hex7toStr(hexChar2)#>
<CFSET hexStr3 = #Hex7toStr(hexChar3)#>
<CFSET hexStr4 = #Hex7toStr(hexChar4)#>
<CFSET hexStr5 = #Hex7toStr(hexChar5)#>
<cfoutput>
<table>
<tr><td>#hexChar1#</td><td>#hexStr1#</td></tr>
<tr><td>#hexChar2#</td><td>#hexStr2#</td></tr>
<tr><td>#hexChar3#</td><td>#hexStr3#</td></tr>
<tr><td>#hexChar4#</td><td>#hexStr4#</td></tr>
<tr><td>#hexChar5#</td><td>#hexStr5#</td></tr>
</table>
</cfoutput>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:211429
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