Recent

Author Topic: WideBytesOf, WideStringOf, BytesOf  (Read 13218 times)

Felian

  • Newbie
  • Posts: 3
WideBytesOf, WideStringOf, BytesOf
« on: January 31, 2010, 12:26:36 pm »
Hello. I need help converting my program (multilingual vocabulary tutoring tool) to Lazarus from Delphi. In new version of Delphi where my program was written first, i used WideBytesOf, WideStringOf, BytesOf functions which implemented (in Delphi SysUtils) using TEncoding Delphi class.
  • WideBytesOf converts UnicodeString to an array of bytes (TBytes = array of Byte) interpreting every character as 2 bytes, as i understood
  • WideStringOf converts an array of bytes to UnicodeString interpreting every pair of bytes as a symbol, as i understood
  • BytesOf converts UnicodeString to an array of bytes interpreting every character as 1 byte using the default encoding, as i understood
So i don't know how to implement these functions in Lazarus. Unicode support and manipulating unicode data through buffers of type TBytes is critically needed for my program, so it (was) easy to do and easy to understand. Can you help me, please?
Please sorry for my bad English.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1947
Re: WideBytesOf, WideStringOf, BytesOf
« Reply #1 on: January 31, 2010, 12:59:57 pm »
manipulating unicode data through buffers of type TBytes is critically needed for my program,

Can you explain why? Understanding this is necessary to find a solution for you.

Felian

  • Newbie
  • Posts: 3
Re: WideBytesOf, WideStringOf, BytesOf
« Reply #2 on: February 01, 2010, 03:02:23 am »
I writing program for an university where i'm studying. I created a special dictionary file format which stored encrypted by Vigenère cipher (students must not have an ability to spy). It seems to be apparent to encode data as bytes. The first version (on Delphi, only English-Russian for now, but Unicode supported) of program already taken by educators and it is not very good to change file format used by it now (after that educators will be forced to change their dictionaries).

I think, may be we can convert WideChar to Word and Word to WideChar, and Word to pair of Bytes manually, using typecasts word(wc_var), widechar(word_var) and manupulating it. I'll try. An idea came.
« Last Edit: February 01, 2010, 03:04:38 am by Felian »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12955
  • FPC developer.
Re: WideBytesOf, WideStringOf, BytesOf
« Reply #3 on: February 02, 2010, 01:16:07 pm »
TUnicodestring Routines and classes introduced in D2009 for the most is not yet supported (that includes TEncoding). There is an TUnicodestring but that is more
the TUnicodestring that we _expected_ codegear to add, not the one they _did_ add.

However pre D2009 and FPC do have a widestring unicode type. Might need a bit more coding, but I assume you can
code the routines for widestring.

Felian

  • Newbie
  • Posts: 3
Re: WideBytesOf, WideStringOf, BytesOf
« Reply #4 on: February 02, 2010, 02:06:17 pm »
I'll try when get some free time for that and post here when any result will be achieved.

Thanks to all who replied.

 

TinyPortal © 2005-2018