Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB General » View Thread |
Messages 11 to 20 of 38 total |
ansi export => unicode import |
Mon, Nov 23 2009 3:47 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Malcolm,
<< Thanks James .. but I need it in code. It now seems my only problem is getting rid of the BOM ... >> Yes, you need to strip out the BOM. However, you can also use these functions in the EDB edbcomps.pas unit (source provided with every version of EDB) to translate files: { Text file encodings } ENCODING_UNKNOWN = 0; ENCODING_ANSI = 1; ENCODING_UNICODE = 2; procedure LoadStringsFromStream(Stream: TStream; Strings: TEDBStrings; Encoding: Integer=ENCODING_UNKNOWN); procedure LoadStringsFromFile(const FileName: TEDBString; Strings: TEDBStrings; Encoding: Integer=ENCODING_UNKNOWN); procedure SaveStringsToStream(Stream: TStream; Strings: TEDBStrings; Encoding: Integer=ENCODING_UNKNOWN); procedure SaveStringsToFile(const FileName: TEDBString; Strings: TEDBStrings; Encoding: Integer=ENCODING_UNKNOWN); The TEDBString and TEDBStrings are just mapped to String/WideString/UnicodeString and TStrings/TWideStrings, respectively, depending upon what version of Delphi/C++Builder and EDB you are using. But, it won't matter for the purposes of doing a conversion like this unless you're using < BDS 2006, which is required for TWideStrings support. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Nov 23 2009 3:51 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Malcolm,
Crap, I just noticed that these also write out a BOM at the start of the file. I'll see about adding a parameter for this for the next build. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Nov 23 2009 5:01 PM | Permanent Link |
"Malcolm" | Tim Young [Elevate Software] wrote:
> Malcolm, > > Crap, I just noticed that these also write out a BOM at the start > of the file. I'll see about adding a parameter for this for the > next build. Thanks Tim, I'm on D2009. Everything I read says Delphi does not support BOM-less unicode files. But EDB requires them and so does PHP and MySQL. Unfortunately I can't use your export files directly as I need to convert them to UTF8 for the web .. and guess what that does! All this means that at the moment my first record imported into MySQL has a bad first column value - not good as it is a key field! At least with EDB such an import simply fails. It seems to me that Delphi is going to need a DefuseBOM() function/method before long - even if I have to write it. -- |
Mon, Nov 23 2009 5:44 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Malcolm,
<< Everything I read says Delphi does not support BOM-less unicode files. But EDB requires them >> This will be changing - the import/export is the last thing that is not character set-agnostic, at least with respect to ANSI/Unicode (UTF16). UTF-8 is still something that will come at a later time, most likely in conjunction with the Linux support. -- Tim Young Elevate Software www.elevatesoft.com |
Mon, Nov 23 2009 5:59 PM | Permanent Link |
"Malcolm" | Tim Young [Elevate Software] wrote:
> Malcolm, > > << Everything I read says Delphi does not support BOM-less unicode > files. But EDB requires them >> > > This will be changing - the import/export is the last thing that is > not character set-agnostic, at least with respect to ANSI/Unicode > (UTF16). UTF-8 is still something that will come at a later time, > most likely in conjunction with the Linux support. My need for UTF-8 is not related to EDB. I will have to solve that myself .. but it is the same issue. I am just moaning! -- |
Mon, May 10 2010 2:44 AM | Permanent Link |
Frank | Can anyone tell me what currently is the best way to perform an export/import from Ansi to Unicode?
I have tried it with creating a store and then export table/import table but also get the truncated/incomplete error. |
Mon, May 10 2010 10:53 AM | Permanent Link |
Malcolm Taylor | F.J. Olthuijsen wrote:
> Can anyone tell me what currently is the best way to perform an > export/import from Ansi to Unicode? > > I have tried it with creating a store and then export table/import > table but also get the truncated/incomplete error. It depends on exactly what you want to do. In my case I am faced with a UTF-16 file including a BOM. Until Tim provides a more elegant solution I am stripping the BOM something like this: [code] PROCEDURE TImportForm.DefuseBOM(fname: STRING); VAR fs: INT64; MStream: TMemoryStream; FStream: TFileStream; BEGIN MStream := TMemoryStream.Create; TRY MStream.LoadFromFile(fname); fs := MStream.Size - 2; // asumes a 2-byte BOM !!!!!! MStream.Position := 2; // point at start of data FStream := TFileStream.Create(fname, fmOpenWrite); TRY FStream.CopyFrom(MStream, fs); FStream.Size := fs; FINALLY FStream.Free; END; FINALLY MStream.Free; END; END; [/code] You may first have to read the Ansi file and re-write it as a unicode one, which will probably add a BOM. Then you can strip it as shown above. You should really check for the actual size of the BOM unless you have full control. Malcolm -- |
Mon, May 10 2010 1:33 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | F.J.
<< Can anyone tell me what currently is the best way to perform an export/import from Ansi to Unicode? >> Are you trying to move an entire database from ANSI to Unicode, or just doing an export/import for one table ? -- Tim Young Elevate Software www.elevatesoft.com |
Mon, May 10 2010 2:18 PM | Permanent Link |
Frank | Hi Tim,
I'd like to migrate the entire database. Frank |
Mon, May 10 2010 2:20 PM | Permanent Link |
Frank | Hi Malcolm,
thanks! Hopefully Tim has an "elegant" alternative. Otherwise I'll give this a try. Frank "Malcolm" wrote: F.J. Olthuijsen wrote: > Can anyone tell me what currently is the best way to perform an > export/import from Ansi to Unicode? > > I have tried it with creating a store and then export table/import > table but also get the truncated/incomplete error. It depends on exactly what you want to do. In my case I am faced with a UTF-16 file including a BOM. Until Tim provides a more elegant solution I am stripping the BOM something like this: [code] PROCEDURE TImportForm.DefuseBOM(fname: STRING); VAR fs: INT64; MStream: TMemoryStream; FStream: TFileStream; BEGIN MStream := TMemoryStream.Create; TRY MStream.LoadFromFile(fname); fs := MStream.Size - 2; // asumes a 2-byte BOM !!!!!! MStream.Position := 2; // point at start of data FStream := TFileStream.Create(fname, fmOpenWrite); TRY FStream.CopyFrom(MStream, fs); FStream.Size := fs; FINALLY FStream.Free; END; FINALLY MStream.Free; END; END; [/code] You may first have to read the Ansi file and re-write it as a unicode one, which will probably add a BOM. Then you can strip it as shown above. You should really check for the actual size of the BOM unless you have full control. Malcolm -- |
« Previous Page | Page 2 of 4 | Next Page » |
Jump to Page: 1 2 3 4 |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |