Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread UTF-16LE support
Thu, Jul 24 2014 6:27 AMPermanent Link

Enrico Lago


Hi. My machine is setup in italian language. I need to store in a memo field both italian, chinese, english and slovak language.
Is there a way? If I put a chinese text in a memo field it will appears like this:


????????,?????????????,?????????

but the text is

政治营运费用报告,从国营电视台到公务员退休金,意大利当局拟采取撙
Thu, Jul 24 2014 6:39 AMPermanent Link

Matthew Jones

Enrico Lago wrote:

>
> Hi. My machine is setup in italian language. I need to store in a
> memo field both italian, chinese, english and slovak language.  Is
> there a way?

Either you have to convert the UTF16 into UTF8 and make the AnsiString
happy (it can be done with care), or you could encode it somehow. It
looks to me like the &#..; is encoding done by a web system. That might
be a sensible option, but of course you need to decode it before
display. Either way, you have to be clear where you are using one
system and where you need to convert.


--

Matthew Jones
Thu, Jul 24 2014 7:18 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Enrico


You have two different problems. You can store the data in a memo field since at the end of the day its just bits but to display it you need a unicode enabled control.

DBISAM itself isn't unicode enabled so you'll need to be careful about how you store multiple languages into one field.

From your post it isn't clear wether you intend to store all languages in each row, just one of them or some selection of the four. If its just one language I'd suggest a helper field to tell you what the language is, if more than one I'd devise a structure to use so that you know where each language is. I'd go for uuencode - simple and fast and you could have 4 lines in each memo field each holding one language.

You will need to decode and display appropriately and I'd recommend using a none databound control.

Search for Delphi TNT unicode through google for the freeware tnt controls. This http://www.axolot.com/TNT/ was the first hit when I did it.

Roy Lambert
Thu, Jul 24 2014 8:07 AMPermanent Link

Enrico Lago

Now I try to explain better.
I have a table with a name, surname and description field.
Each field is memo.
Sometimes I need to store the description in italian language, sometimes in chinese or other language. Is possible?
Try with dbsys.exe. I can only in italian language.
If I try with sqlite or another program, I can store information in italian, chinese or other.

With Delphi I can create an xml file using UTF-16LE encoding without any problem with both italian, english, chinese language.
Thu, Jul 24 2014 8:28 AMPermanent Link

Raul

Team Elevate Team Elevate

On 7/24/2014 8:07 AM, Enrico Lago wrote:
> Sometimes I need to store the description in italian language, sometimes in chinese or other language. Is possible?
> Try with dbsys.exe. I can only in italian language.

DBISAM is not unicode enabled so you cannot store multiple languages in
the same field without you having to manually manipulate some of this -
basically you have to convert you unicode string to one of the unicode
encodings and store it and when reading convert it back again manually.

Assuming you use Delphi 2009 or later your delphi components
(edit/memo/etc) would be unicode enabled but you'd still need to handle
the save/load of data from database.
if you're using D2007 or earlier then you need unicode enabled controls
also so follow Roy-s suggestion on TNT ones for example.

> If I try with sqlite or another program, I can store information in italian, chinese or other.

If they are unicode enabled databases and apps then yes they work fine.

DBISAM is not a unicode database so it won't just work automatically and
you need to think of database save as "convert unicode string to a
unicode encoding and store as bytes" and similarly db field read is
"read bytes in unicode encoding aned convert to unicode string".

Elevate other product - ElevateDB - is fully unicode enabled so using
EDB Manager (dbisam equivalent in EDB) or D2009 app or newer would also
automatically work.

Raul
Thu, Jul 24 2014 8:34 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Enrico

<<If I try with sqlite or another program, I can store information in italian, chinese or other.

With Delphi I can create an xml file using UTF-16LE encoding without any problem with both italian, english, chinese language.>>

That says that sqlite is unicode enabled, and so is the version of Delphi you're using. Windows definitely is.


From an earlier post of Tim's

<<Yes, but DBISAM cannot store Unicode strings directly.  It can store MBCS
strings as ANSI strings, and always uses ANSI strings for all storage and
formats, even under Delphi 2009 or higher.>>

So, as both Matthew and I have said, you'll need to encode it somehow. You could switch to ElevateDB which is unicode enabled.


Here's a compilation that searching the DBISAM newsgroups showed me

------------------------------------------------------------------------------------------------------------------------------------------
> Are there any DBISAM issues I should anticipate, other than the obvious
> differences in decimal separator, currency symbol, and list separator
across
> countries? Would exchange of databases between customers of different
> languages be possible?

A key issue with languages like Japanese is usually UNICODE/WideChar. DBISAM
does not understand MBCS so, although it can store the raw data, it cannot
index of query it properly.

> Most likely the project would be done with DBISAM 2.

DBISAM V2.x and V3.x are the same in the above respect howver V3.x does
simplify date formatting issues in SQL etc. as it forces ANSI standard
format of yyyy-mm-dd (which I think is everyday Japanese default anyway).
------------------------------------------------------------------------------------------------------------------------------------------
<< Please answer me that Can DBISAM search or query data in memo as unicode
UTF-8 , and give me a example please. >>

DBISAM only supports the use of the ANSI character set.
------------------------------------------------------------------------------------------------------------------------------------------
> Any chance you can think again?  Unicode is very important to us, for
several
> reasons. We need to display Cyrillic and West European text
simultaneously. We
> need to display chemical formulas with subscripted numbers (e.g.H2SO4).
And we
> are about to add Japanese and Chinese to our application, and for sure we
will
> want to display West European text alongside these Asian languages.

See http://home.ccci.org/wolbrink/tntmpd/delphi_unicode_controls_project.htm

This component allow encoding Unicode strings into a non-Unicode database.
------------------------------------------------------------------------------------------------------------------------------------------
>
> See
http://home.ccci.org/wolbrink/tntmpd/delphi_unicode_controls_project.htm
>
> This component allow encoding Unicode strings into a non-Unicode database.
>

We are now using it for editing and displaying unicodes. However, when the
data was saving into the String field of DBISAM, the content would be
altered by the engine. We have to use the Byte fields to store unicodes that
works but require a lot of extra coding in saving and retrieving data.
------------------------------------------------------------------------------------------------------------------------------------------
> What is the recommended way to store unicode data in a record? I just need
> to store and display chinese characters. I will not have to search, sort
or
> process them in any way. I am using the TntDbEdit component but if I use a
> DBISAM string field I just get ??????. Frown

DBISAM does not 'understand' Unicode/WideChar etc. so it would be best to
store the data in a generic binary field type ....bytes or BLOB.
------------------------------------------------------------------------------------------------------------------------------------------


Roy Lambert
Thu, Jul 24 2014 9:04 AMPermanent Link

Matthew Jones

Raul wrote:

> Elevate other product - ElevateDB - is fully unicode enabled so using
> EDB Manager (dbisam equivalent in EDB) or D2009 app or newer would
> also automatically work.

Having just converted an application from DBISAM to ElevateDB, I'll
just add that this was very simple - I posted about it here. All a lot
easier than you might think. I took a backup of everything, started,
and the core was done within a day. Much more flexible, and fully
Unicode capable.

--

Matthew Jones
Image