Unicode string parsing? Please help!

D

Douglas Gennetten

I am trying to parse a string and create a list of character codes. For
example,

"MUM" converts to " 0x004D, 0x0055, 0x004D"

With ascii text, I have accomplished this with Hex(Asc(Mid(asciiString, i,
1)).

How can I do something similar with double-byte text such as Korean
where these ascii functions no longer apply?

Thanks,

Douglas Gennetten
 
M

Martin Seelhofer

Hi Douglas

Nowadays, every VBA-string is UNICODE but VBA hides
this situation from you (mostly, that is). However, there are
functions able to deal with this:

AscB(...) --> Returns the ASCII-code for a given byte
MidB(...) --> Returns a byte (not a character)

With these, you can write something like (Immediate window):

?AscB(MidB("Hello world",1,1))
72

?AscB(MidB("Hello world",2,1))
0

?AscB(MidB("Hello world",3,1))
101

As you can see, MidB lets you access all the bytes of the
16-Bit Unicode-string and not just every second one as the
normal Mid-function seems to do. However, you may have
to jump over the codepage-values (every second byte, in
the above example the 0-values) yourself...


Cheers,
Martin


There should be
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top