| View previous topic :: View next topic |
| Author |
Message |
chenchenwag How do I cheat?
Reputation: 0
Joined: 21 Jan 2008 Posts: 2
|
Posted: Tue Jan 22, 2008 9:33 pm Post subject: Unicode Bug!!!! |
|
|
function TScanner.CaseSensitiveUnicodeStringExact(newvalue,oldvalue: pointer):boolean;
var i: integer;
begin
result:=false;
for i:=1 to length(scanvalue1 ) do
if widescanvalue1[i]<>(pwidechar(newvalue)[i-1]) then exit;
result:=true;
end;
function TScanner.CaseInsensitiveUnicodeStringExact(newvalue,oldvalue: pointer):boolean;
var i: integer;
scanvaluellength: integer;
pwidescanvalue: pchar;
begin
result:=false;
i:=0;
scanvaluellength:=length(scanvalue1 )*sizeof(widechar);
pwidescanvalue:=@widescanvalue1[1];
for i:=1 to length(scanvalue1 ) do
begin
if pchar(newvalue)[(i-1)*sizeof(wchar)] in ['a'..'z'] then //change to uppercase
dec(pbytearray(newvalue)[(i-1)*sizeof(wchar)],$20);
if widescanvalue1[i]<>(pwidechar(newvalue)[i-1]) then exit;
end;
result:=true; //it got here, so a match
end;
(scanvalue1) should be (widescanvalue1)
I am Chinese, My english is poor!
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 475
Joined: 09 May 2003 Posts: 25994 Location: The netherlands
|
Posted: Tue Jan 22, 2008 10:28 pm Post subject: |
|
|
you're right
it is an oversight, but the result of length(scanvalue1) and length(widescanvalue1) should be the same (it counts the number of characters, not the number of bytes)
_________________
Tools give you results. Knowledge gives you control.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
chenchenwag How do I cheat?
Reputation: 0
Joined: 21 Jan 2008 Posts: 2
|
Posted: Tue Jan 22, 2008 11:10 pm Post subject: |
|
|
CE source
scanvalue1:string
widescanvalue1:widestring
If the value is double byte (eg. character)
length(scanvalue1) and length(widescanvalue1) won't match
eg
scanvalue1:='中';
length(scanvalue1)=2;
eg
widescanvalue1:='中';
length(widescanvalue1)=1;
|
|
| Back to top |
|
 |
|