Android Question Working with no charset?

W. Graf

Member
Licensed User
Longtime User
Hi!
I'm programming with B4A for a few months. So, I'm no expert ;-)
I have two questions:


Question 1:
Can somebody please tell me, why following happens?
B4X:
Dim StringText As String
Dim ByteConv As ByteConverter
StringText = Chr(0x9c)
Label1.Text = ByteConv.HexFromBytes( ByteConv.StringToBytes(StringText, "Windows-1252") )

If I start the app, I'm getting 1A (and not 9C). Why?
I think, it is a charset-problem (because 0x9C > 128 and so it is converted into a 2-byte-char?!).

My problem is:
I have a file on my smartphone.
I want to read the file via RandomAccessFile into a byte array (-> works).
Then I have to convert the byte array into a string. But I DON'T want to use any charset! I want to copy the bytes from the byte array 1:1 to the string. Yes I know: maybe the string is not readable by a human. Then I will use the string for special algorithms I wrote. At the end, I convert the string 1:1 back to a byte array.
I'm used to program in VB6. I thought, that using the charset "Windows-1252" is equal to "how VB6 works" (my app finally exchanges the data with my VB6 app).
So I'm looking for a method like "CopyMemory" in VB6. I also tried the example above using "ASCII" and "UTF-8" (insted of "Windows-1252"). ASCII returns 3F. "UTF-8" returns C29C. But I only want 9C :)
Do you have an ideas?


Question 2:
Is it possible with B4A to access arrays or variables via pointers directly in memory (like CopyMemory, VarPtr, StrPtr, ... in VB6) to speed up tasks? Maybe an external library?

Thank you very much & wish you a nice day!
Wolfgang
 

W. Graf

Member
Licensed User
Longtime User
Thank you for your quick reply.
1) It's not the answer, I was hoping to get, but now I know, what I have to do ;-)
2) Perfect!
Have a great day!
 
Upvote 0
Top