473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

String translation

I'm reading data from several font file files (designer / copyright / etc)

Several of the strings begin with a chr(63) <might be chr(65) I don't have
one open at the momentand appear to be unicode (2 bytes per char).
Several begin with chr(255) and appear to be charW <??(four bytes per
char)

Most of these appear to be just ascii srings (in presumably different
encoding) as I can read them if I open the font in font browser, the
designer name for example.

I've tried:
Dim unicodeBytes As Byte() = [unicode].GetBytes(strIn)
Dim asciiBytes As Byte() = Encoding.Convert([unicode], ascii, unicodeBytes)
Dim asciiChars(ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)) As Char
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
Dim asciiString As New String(asciiChars)
Return asciiString
I'm getting nothing sensible back. Is the initial character (63 / 255) I'm
seeing part of the string? Any suggestions on how to make this conversion
work as I'd like it to?

Thanks //al
Jul 30 '06 #1
2 1381
The stream reader can detect the byte order mark by itself use this option
when reading files where you do not know for sure what the encoding is
regards

Michel Posseth [MCP]

"al jones" <al**********@shotmail.comschreef in bericht
news:67******************************@40tude.net.. .
I'm reading data from several font file files (designer / copyright / etc)

Several of the strings begin with a chr(63) <might be chr(65) I don't have
one open at the momentand appear to be unicode (2 bytes per char).
Several begin with chr(255) and appear to be charW <??(four bytes per
char)

Most of these appear to be just ascii srings (in presumably different
encoding) as I can read them if I open the font in font browser, the
designer name for example.

I've tried:
> Dim unicodeBytes As Byte() = [unicode].GetBytes(strIn)
Dim asciiBytes As Byte() = Encoding.Convert([unicode], ascii,
unicodeBytes)
Dim asciiChars(ascii.GetCharCount(asciiBytes, 0,
asciiBytes.Length)) As Char
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
Dim asciiString As New String(asciiChars)
Return asciiString

I'm getting nothing sensible back. Is the initial character (63 / 255)
I'm
seeing part of the string? Any suggestions on how to make this conversion
work as I'd like it to?

Thanks //al

Jul 30 '06 #2
Wish I could, these are random access reads within the file. Thanks for
the thought. //al

On Sun, 30 Jul 2006 13:21:32 +0200, Michel Posseth [MCP] wrote:
The stream reader can detect the byte order mark by itself use this option
when reading files where you do not know for sure what the encoding is

regards

Michel Posseth [MCP]

"al jones" <al**********@shotmail.comschreef in bericht
news:67******************************@40tude.net.. .
>I'm reading data from several font file files (designer / copyright / etc)

Several of the strings begin with a chr(63) <might be chr(65) I don't have
one open at the momentand appear to be unicode (2 bytes per char).
Several begin with chr(255) and appear to be charW <??(four bytes per
char)

Most of these appear to be just ascii srings (in presumably different
encoding) as I can read them if I open the font in font browser, the
designer name for example.

I've tried:
>> Dim unicodeBytes As Byte() = [unicode].GetBytes(strIn)
Dim asciiBytes As Byte() = Encoding.Convert([unicode], ascii,
unicodeBytes)
Dim asciiChars(ascii.GetCharCount(asciiBytes, 0,
asciiBytes.Length)) As Char
ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0)
Dim asciiString As New String(asciiChars)
Return asciiString

I'm getting nothing sensible back. Is the initial character (63 / 255)
I'm
seeing part of the string? Any suggestions on how to make this conversion
work as I'd like it to?

Thanks //al
Jul 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: John Leslie | last post by:
I need to write a string to a file in EBCDIC. Do I need to do it character by character using a translation table, or is there a function to translate the whole string? (I am aware that I can...
47
by: sudharsan | last post by:
could any one please give me a code to reverse a string of more than 1MB .??? Thanks in advance
6
by: nrperry | last post by:
Hello, I have a question about this error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -2 I am doing my java development in IBM Rationale...
8
by: Pan | last post by:
#include <stdio.h> #define MYSTR "World" void foo(char *p) { puts(p); } int main() {
2
by: Konstantinos Pachopoulos | last post by:
Hi, i have the following string s and the following code, which doesn't successfully remove the "\", but sucessfully removes the "\\". .... if i!="\\": .... newS=newS+i .......
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.