PB_Unicode string compare fails?!?!

Just starting out? Need help? Post your questions and find answers here.
rchaney
New User
New User
Posts: 3
Joined: Fri May 18, 2018 2:15 pm

PB_Unicode string compare fails?!?!

Post by rchaney »

The two strings x$ and y$ SHOULD be identical, but are not is some "invisible" way!
The Unicode string is 2 bytes longer, perhaps this is the reason for the compare failure?
Debug output shows them identical!

Thanks,
Richard

Code:

Code: Select all

    x$ = StringField(ReadString(0,#PB_Unicode), #fid, fd$)
    y$ = "#Device ID"
    Debug x$
    Debug StringByteLength(x$)
    Debug y$
    Debug StringByteLength(y$)
    Trim(x$)
    Debug x$
    Debug StringByteLength(x$)
Debug Output:
#Device ID
22
#Device ID
20
#Device ID
22
__________________________________________________
Code and quote tags added
05.06.2018
RSBasic
User avatar
Demivec
Addict
Addict
Posts: 4091
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: PB_Unicode string compare fails?!?!

Post by Demivec »

Why don't you display the ASCII value of each character in the strings?

In unicode not all code point values are visible characters.
Fred
Administrator
Administrator
Posts: 16681
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB_Unicode string compare fails?!?!

Post by Fred »

Without your file, it's hard to say. Did you check for the BOM with ReadFileFormat() ?
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: PB_Unicode string compare fails?!?!

Post by kenmo »

1. Check the string bytes

Code: Select all

ShowMemoryViewer(@x$, StringByteLength(x$))
ShowMemoryViewer(@y$, StringByteLength(y$))
2. Trim() is not used correctly

Code: Select all

;Trim(x$)
x$ = Trim(x$)
Post Reply