String translation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • al jones

    #1

    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.Conver t([unicode], ascii, unicodeBytes)
    Dim asciiChars(asci i.GetCharCount( asciiBytes, 0, asciiBytes.Leng th)) As Char
    ascii.GetChars( asciiBytes, 0, asciiBytes.Leng th, asciiChars, 0)
    Dim asciiString As New String(asciiCha rs)
    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
  • Michel Posseth  [MCP]

    #2
    Re: String translation

    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" <alfredmjones@s hotmail.comschr eef in bericht
    news:67tpu8fe09 z8$.15aiuevlxnw kg$.dlg@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.Conver t([unicode], ascii,
    >unicodeBytes )
    > Dim asciiChars(asci i.GetCharCount( asciiBytes, 0,
    >asciiBytes.Len gth)) As Char
    > ascii.GetChars( asciiBytes, 0, asciiBytes.Leng th, asciiChars, 0)
    > Dim asciiString As New String(asciiCha rs)
    > 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

    Comment

    • al jones

      #3
      Re: String translation

      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" <alfredmjones@s hotmail.comschr eef in bericht
      news:67tpu8fe09 z8$.15aiuevlxnw kg$.dlg@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.Conver t([unicode], ascii,
      >>unicodeByte s)
      >> Dim asciiChars(asci i.GetCharCount( asciiBytes, 0,
      >>asciiBytes.Le ngth)) As Char
      >> ascii.GetChars( asciiBytes, 0, asciiBytes.Leng th, asciiChars, 0)
      >> Dim asciiString As New String(asciiCha rs)
      >> 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

      Comment

      Working...