PDA

View Full Version : ASCII escaping used by command line interface



jlo
2005-06-07, 19:35
hi folks,

I am current retrofitting an automation systems use the socket command line interface of the slimserver. The issue I had ran into is that the automation system process a lot of Chinese and Japanese mp3s and with those characters in ID3 tags.

The command line interface outputs those characters in ASCII escape chars (like IE does when you put a chinese character in google search, look at the http query string), however, I have not been able to find a tool in VB6 to unescape it. The only escape function I wa sable to get it to run is to use vbscript functions, and it does unicode escaping, not ASCII.

For Chinese characters, normally 1 characters is made of 1 unicode char or 2 ASCII chars, so it complicated things a lot...

I am just hoping maybe someone here know about how to do ASCII escaping in VB6, so I can get this over with. I have friends told me Flash can do this just fine, since the GUI for the automation system is written in Flash, I might just let the GUI developer deal with this.

anyway, thanks in advance for any help given here.

- James

Marc Sherman
2005-06-08, 05:32
jlo wrote:
>
> The command line interface outputs those characters in ASCII escape
> chars (like IE does when you put a chinese character in google search,
> look at the http query string), however, I have not been able to find a
> tool in VB6 to unescape it. The only escape function I wa sable to get
> it to run is to use vbscript functions, and it does unicode escaping,
> not ASCII.

Google is quite happy to help, if you search for the right thing:
http://www.google.ca/search?q=urldecode+vb

- Marc

jlo
2005-06-08, 18:55
Marc,

thank you for the reply. However, using the chr and chrw functions was my first attempt at this, and it doesn't work. That's why I am looking for the sepcifical escape function. With a single ASCII char the VB functions work well, but for Chinese, it required 2 ASCII characters for each character, and simply display the 2 chr() characters in row does not show the Chinese character unfortunely. The escape and unescape function I used for uincode was able to do this just fine, but not for ASCII ones.

I am only doing this because the CLI outputs ASCII escaping characters. I have heard other language (such as Greek, etc) had similar issues. maybe some european and asian develoepers can help me out, thanks.

- James

Fred
2005-06-09, 15:26
James,

OK, not sure I understand your problem really, not used to VB. Here is
how things work:

SlimServer works in UTF-8. In UTF-8 any char above 0x7F uses 2 (or more)
bytes, below 0x7F UTF-8 == ASCII and one byte per char.

This is *ignored* by the url encoding function that works on BYTES. It
will replace each byte by %xx according to the rules.

At the receiving side, you need to url decode at the byte level and then
have your software consider the resulting bytes as an UTF-8 string. If
your application expects something else (big 5, say, for Chinese), you
need to perform an UTF-8 -> big 5 translation.

Now, SlimServer somehow guesses the charset of the tags (UTF-8 or the OS
locale). If the songs are tagged in an exotic charset, Slimserver will
be confused and the output will be garbage. Are you chinese customers
able to read the tags OK on the SlimServer web GUI? If yes then that
point is OK.

Hope this helps

Fred






jlo wrote:

> Marc,
>
> thank you for the reply. However, using the chr and chrw functions was
> my first attempt at this, and it doesn't work. That's why I am looking
> for the sepcifical escape function. With a single ASCII char the VB
> functions work well, but for Chinese, it required 2 ASCII characters
> for each character, and simply display the 2 chr() characters in row
> does not show the Chinese character unfortunely. The escape and
> unescape function I used for uincode was able to do this just fine, but
> not for ASCII ones.
>
> I am only doing this because the CLI outputs ASCII escaping characters.
> I have heard other language (such as Greek, etc) had similar issues.
> maybe some european and asian develoepers can help me out, thanks.
>
> - James
>
>

jlo
2005-06-09, 19:02
Fred,

you pretty much answer my question of why any of my decoding had failed so far. There is not a native VB6 UTF-8 encoding and decoding functions (this can be done very very easily in .net). I am now searching for a way to do this in VB6. (no luck so far)

And yes, the slimserver web GUI is displaying the Chinese character just fine, so the character set is ok.

radish
2005-06-09, 20:08
Google found this page for me:

http://www.vovisoft.com/unicode/UniFunctions.htm

It's not in english, but the functions look useful. Something there to convert to/from UTF-8 and VB 'String' type.