Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

utf-8 problem?

Status
Not open for further replies.

jslmvl

Vendor
Jan 26, 2008
268
GB
Hi,

There are two data, ?????? and 123456, in the same field (Data Type is Text) of a table in an Access file.
I cannot change that field to "No Duplicates" because Access thinks those two data are equal.
After read those data to d1 and d2 in ASP (codepage=65001, charset=utf-8), I found thy are not equal by the code "If d1=d2 Then"!
Anything wrong?
 
If the processing is in-memory, you can pass the retrieved value through a conversion. The number-string's origin is probably through an encoding scheme of shift-jis or alike.

The pass-through can be done via a function like this.
[tt]
'...etc etc
'd1, d2 are the retrieved data, the numbers in question
if cvt_sjis_ascii_number(d1)=cvt_sjis_ascii_number(d2) then
'do something...
else
'do some other thing...
end if
'etc etc...

function cvt_sjis_ascii_number(s)
dim t, i, j, schar
dim u(1)
t=""
for i=0 to lenb(s)-1 step 2
for j=1 to 0 step -1
schar=midb(s,i+j+1,1)
u((j+1) mod 2)=right("0" & hex(ascb(schar)),2)
next
if u(0)="FF" and cint(u(1))>=10 and cint(u(1))<=19 then
t=t & chr(cint("&H"&u(1))+&H20)
else
cvt_sjis_ascii_number=s
exit function
end if
next
cvt_sjis_ascii_number=t
end function
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top