Login ProductsSalesSupportDownloadsAbout |
Home Technical Support DBISAM Technical Support Support Forums DBISAM General View Thread |
Messages 1 to 5 of 5 total |
Write Delphi 2009 russian text to DBISAM |
Tue, Jun 24 2014 8:14 AM | Permanent Link |
john | I have been trying to add russian text to my application.
now i have been reading about the vlc components not supporting unicode strings so i will need to update my vlc components. But i also tested adding russian text directly into the DBISAM database (as .value:=) and i cant get it to work. i keep ending up with the question marks like "??????-????? ???? ???". I have tried to read the value from the database string field back into Delphi but the result is still the question marks. Can anyone help me with how i can get this to work ? Thanks, |
Tue, Jun 24 2014 8:56 AM | Permanent Link |
Raul Team Elevate | On 6/24/2014 8:14 AM, john wrote:
> now i have been reading about the vlc components not supporting unicode strings so i will need to update my vlc components. If you're on D2009 then unicode support is built-in (d2009 was the first unicode delphi supporting unicode for both VCL and string type). > But i also tested adding russian text directly into the DBISAM database (as .value:=) and i cant get it to work. i keep ending up with the question marks like "??????-????? ???? ???". > I have tried to read the value from the database string field back into Delphi but the result is still the question marks. However DBISAM does not support Unicode. > Can anyone help me with how i can get this to work ? If you can switch to EDB instead of DBISAM then it has built-in unicode support. For DBISAM one option would be to switch to ANSI strings - looks like code page 1251 provides most of the Cyrillic characters - so using that might work for you. You'd need to declare all the strings with the right codepage and make sure the conversion works ok (i.e. when assigning TEdit value to your cp1251 string, You could also convert to/from utf8 for actual DBISAM storage - internally manage it as a unicode string but convert to utf8 before saving and from utf8 before loading. Raul |
Tue, Jun 24 2014 10:43 AM | Permanent Link |
john | Thanks for the reply, verry helpfull.
It is verry nice to see i no longer have to worry about vlc... but pitty my DBISAM cant use it Switching out DBISAM is kinda a problem for me so your option about codepage sounds intresting. can you explain to me in more detail how this codepage works? Thanks, Raul wrote: On 6/24/2014 8:14 AM, john wrote: > now i have been reading about the vlc components not supporting unicode strings so i will need to update my vlc components. If you're on D2009 then unicode support is built-in (d2009 was the first unicode delphi supporting unicode for both VCL and string type). > But i also tested adding russian text directly into the DBISAM database (as .value:=) and i cant get it to work. i keep ending up with the question marks like "??????-????? ???? ???". > I have tried to read the value from the database string field back into Delphi but the result is still the question marks. However DBISAM does not support Unicode. > Can anyone help me with how i can get this to work ? If you can switch to EDB instead of DBISAM then it has built-in unicode support. For DBISAM one option would be to switch to ANSI strings - looks like code page 1251 provides most of the Cyrillic characters - so using that might work for you. You'd need to declare all the strings with the right codepage and make sure the conversion works ok (i.e. when assigning TEdit value to your cp1251 string, You could also convert to/from utf8 for actual DBISAM storage - internally manage it as a unicode string but convert to utf8 before saving and from utf8 before loading. Raul |
Tue, Jun 24 2014 7:59 PM | Permanent Link |
Raul Team Elevate | On 6/24/2014 10:43 AM, john wrote:
> Thanks for the reply, verry helpfull. > > It is verry nice to see i no longer have to worry about vlc... but pitty my DBISAM cant use it > > Switching out DBISAM is kinda a problem for me so your option about codepage sounds intresting. > can you explain to me in more detail how this codepage works? > DBISAM is not Unicode so it stores (and displays) everything using local OS code page. This also means that whoever is using your application must be using russian locale on their machine. Cyrillic letters fit into code page 1251 so you can store the russian text into dbisam as long as it's converted from Unicode string to ansi string. If your computer locale is already russian then you can just use AnsiString as is (otherwise you can always define your own custom code page string type) and then you can just do something like this (assuming there is an TEdit that user entered russian text) : type MyRussianString = type Ansistring(1251) .... procedure DoSomething(); var strRus:MyRussianString; begin strRus := Edit1.Text; //use strRus as you normally would // ... MyDBISAMTable.FieldByName('text').AsAnsiString := strRus; // .... That's all there is to it. for example let's say user enters a word "Спасибо" which in unicode is a string with code points of U+421, U+43F, U+430, U+441, U+438, U+431 and U+43E. "strRus := Edit1.Text" - Delphi does automatic conversion for you here so you end up with code page 1251 characters of D1, EF, E0, F1, E8, E1 and EE. Note that if your OS code page is NOT russian then you you end up with ?????. For example latin 1252 code page has no mapping from U+421 and other code points hence the "?" if you were to directly assign unicode string to ansi 1252 string. This also means that you cannot really have 2 non-ASCII character set users using the same DBISAM database. Technically they can but data will look weird as its displayed with wrong code page (so if they only see their own data i guess it might be ok). For example if i were to open the database with dbsys on my os (code page 1252) and look at that entry that stores "Спасибо" i'd actually see "Ñïàñèáî" (this is still correct character codes but it makes no sense in latin code page). Hope this helps. Raul |
Wed, Jun 25 2014 4:05 AM | Permanent Link |
john | Thanks for you help !
i tryed the ansistring(1251) but with my OS language set to default this still shows "??? ??". So i did as you explained and tested it with my OS language set to Russian. ( in the discription of this option windows talks about unicode and older programs ) This directly made it posible to write and read the russian text in my test program and also in the live version of the program. for now this is the best solution for me. and in the future a update to the new database is allot more intresting now. Thank you allot for your exelent help! |
This web page was last updated on Thursday, March 28, 2024 at 06:18 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |