Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Dec 16, 2019 12:54 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: String encoding issue
PostPosted: Sat Nov 19, 2011 7:44 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
Hi,

I have an old VB6 INI file that I have to read into my new RB version.... there is a hashed string in there so that user cannot change it by opening and editing the file... This string has some odd non-ascii like characters. Here is an example:

Name=6ƒ¨¡§YŠgYŒ°¢Ÿ­eY|‰zeY|‰

I am using this type of code to read in the entore ini file:

Do Until InputStream.EOF
sLine = Trim(InputStream.ReadLine)
Loop

In there I also grab and parse each line...
My issue is that if I throw a message box of the read in Name string it only displays the ascii characters... at first I thought it was not reading it all in but LenB indicates the string is of the correct length.

However, my converted uncrypt/unhash code pulls out only like 5 characters of the original.....

Not sure how to debug this... how to determine if this is an encoding problem on the read in or conversion... or whether to pursue the decrypt code not being translated right.... I was trying to first verify the correct string got read in from the file... not sure how to do that though...

Any ideas appreciated.

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
Reply with quote  
 Post subject: Re: String encoding issue
PostPosted: Sat Nov 19, 2011 9:30 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
After you read the string, use DefineEncoding to tell RB what the encoding is, so it can handle the characters correctly. What is the encoding, anyway? I don't think VB was very encoding savvy.


Top
 Profile  
Reply with quote  
 Post subject: Re: String encoding issue
PostPosted: Sat Nov 19, 2011 9:35 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
It was a near novice programmer that just took the letters of someone's name, converted to ascii, and then just did various minor math on it... and converted back to ascii and saved it... so it has a bunch of non letter, non number non punctuation characters.... I really don't know what to call this "encoding"... I have the encode and decode routines... but they aren't working so am concerned we are not passing in the raw string or that it is filtered... I tried setting our string to variant just in case... it didn't help though.

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
Reply with quote  
 Post subject: Re: String encoding issue
PostPosted: Sat Nov 19, 2011 10:04 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
So its a bunch of values from 0 to 255? Ie., each byte stands alone? Then use a memoryblock or use the B versions of the string functions (LenB, MidB, etc.) and take encodings out of the equation altogether. Memoryblock might be the easiest to use, since you can get the numeric value of each byte directly.


Top
 Profile  
Reply with quote  
 Post subject: Re: String encoding issue
PostPosted: Sun Nov 20, 2011 7:39 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
I used the B versions of Len, Mid, Asc etc. and it fixed the problem!

I was thrown for a mental loop because Len returned the wrong length and if I did a MsgBox of the string it had only half the chars...... The full string was there all along but I think RB ignores those other weird binary characters...

Anyway got it working...

Thanks.

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
Reply with quote  
 Post subject: Re: String encoding issue
PostPosted: Sun Nov 20, 2011 11:39 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
It doesn't ignore those bytes, it interprets multiple bytes as a single character. That's what encodings are all about. You just want to ignore encodings and deal with bytes instead of characters.

characters <> bytes


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group