[DUG] Unicode help in D7

Todd Martin todd.martin.nz at gmail.com
Wed Oct 3 19:16:15 NZDT 2012


Hi Ross

XE2 doesn't force you to store data in UTF-16 format. It is simply the
encoding used internally by Delphi > 2009 for strings.

Todd.
>
> I know what your saying, but it won’t be a biggie if I upgrade one day.
>
>  
>
> I store filenames in text files on the hard drive and also in RAM, and
> some customers have 500,000+ files.  Doubling the RAM and hard drive
> space requirements doesn’t appeal when most of my customers are in
> western countries.  That is my main reason to use UTF-8 over UTF-16.
>
>  
>
> Ross.
>
>  
>
> *From:*delphi-bounces at listserver.123.net.nz
> [mailto:delphi-bounces at listserver.123.net.nz] *On Behalf Of *John Bird
> *Sent:* Wednesday, 3 October 2012 12:03 p.m.
> *To:* muellers at orcl-toolbox.com; NZ Borland Developers Group - Delphi List
> *Subject:* Re: [DUG] Unicode help in D7
>
>  
>
> I would second upgrading to XE2/XE3 as almost all of the Unicode
> housekeeping is done automatically in later versions of Delphi – and
> if you start coding for AnsiChar/WideChar etc then you will have
> considerable code to unwind when you do convert as the workarounds are
> not needed
>
>  
>
> John Bird
>
> *From:*Stefan Mueller <mailto:muellers at orcl-toolbox.com>
>
> *Sent:*Tuesday, October 02, 2012 11:57 PM
>
> *To:*'NZ Borland Developers Group - Delphi List'
> <mailto:delphi at listserver.123.net.nz>
>
> *Subject:*Re: [DUG] Unicode help in D7
>
>  
>
> The problem with storing Unicode in utf8 is that the caller always
> needs to know whether a string contains ansi or utf8 and that can get
> messy/buggy real quick if you have a big project
>
>  
>
> I am sure you have thought about it and you have your own reason. But
> as far as I am concerned, if you go down that road to slowly Unicode
> enable your application (including later on maybe Form captions,
> labels, edits, listboxes, etc) then using widestring and something
> like TNT library on delphi7 is the easiest way (or upgrade to >delphi2009)
>
>  
>
>
> Kind Regards,
> Stefan Mueller
> _______________________
> R&D Manager
> ORCL Toolbox LLP, Japan
> http://www.orcl-toolbox.com <http://www.orcl-toolbox.com/>
>
>  
>
>  
>
> *From:*delphi-bounces at listserver.123.net.nz
> <mailto:delphi-bounces at listserver.123.net.nz>
> [mailto:delphi-bounces at listserver.123.net.nz] *On Behalf Of *Ross Levis
> *Sent:* Tuesday, October 02, 2012 7:25 PM
> *To:* 'NZ Borland Developers Group - Delphi List'
> *Subject:* Re: [DUG] Unicode help in D7
>
>  
>
> I’ve hit a snag.
>
>  
>
> D7 defines IShellLinkW like this.
>
>  
>
>   IShellLinkW = interface(IUnknown) { sl }
>
>     [SID_IShellLinkW]
>
>     function GetPath(pszFile: PWideChar; cchMaxPath: Integer;
>
>       var pfd: TWin32FindData; fFlags: DWORD): HResult; stdcall;
>
>  
>
> I think the TWin32FindData should be TWin32FindDataW.  I take it this
> is a bug, and I’ll define my own one.
>
>  
>
> Ross.
>
>  
>
> *From:*delphi-bounces at listserver.123.net.nz
> <mailto:delphi-bounces at listserver.123.net.nz>
> [mailto:delphi-bounces at listserver.123.net.nz]
> <mailto:[mailto:delphi-bounces at listserver.123.net.nz]> *On Behalf Of
> *Ross Levis
> *Sent:* Tuesday, 2 October 2012 10:58 p.m.
> *To:* 'NZ Borland Developers Group - Delphi List'
> *Subject:* Re: [DUG] Unicode help in D7
>
>  
>
> Thanks for that.  I did download some free 3^rd party components and
> pas files I found which include a TOpenDialogW, WideFindFirst,
> WideFileExists, etc.  They should be all I need.
>
>  
>
> I’ll actually be storing everything in UTF8 and converting backwards
> and forwards to full unicode as required for the Windows API.  That
> way I can keep most of my code using the default AnsiString, standard
> TStringLists, etc.
>
>  
>
> For me it would be useful if someone had created a set of UTF8
> components.  I find it so much easier to work with.  I’ve created a
> UTF8FileExists function, for example.  I suppose later Delphi versions
> to the conversions automatically.
>
>  
>
> Cheers,
>
> Ross.
>
>  
>
> *From:*delphi-bounces at listserver.123.net.nz
> <mailto:delphi-bounces at listserver.123.net.nz>
> [mailto:delphi-bounces at listserver.123.net.nz] *On Behalf Of *Stefan
> Mueller
> *Sent:* Tuesday, 2 October 2012 9:22 p.m.
> *To:* 'NZ Borland Developers Group - Delphi List'
> *Subject:* Re: [DUG] Unicode help in D7
>
>  
>
> The buffer has to be WideChar if you use the IShellLinkW interface.
>
>  
>
> I also had my software unicodified with delphi7. I used the TNT
> components (last free version is here: http://www.axolot.com/TNT/ - it
> got bought out by TMS software:
> http://www.tmssoftware.com/site/tmsuni.asp ) and that made things very
> easy.
>
>  
>
> The TNT component pack adds Unicode enabled VCL-controls as well as
> Unicode Windows-API support for many
> functions(FileOpen,FileCreate,etc) and classes(WideStringList, etc).
> The library makes it easy to be dealing with Unicode.
>
>  
>
>
> Kind Regards,
> Stefan Mueller
> _______________________
> R&D Manager
> ORCL Toolbox LLP, Japan
> http://www.orcl-toolbox.com <http://www.orcl-toolbox.com/>
>
>  
>
>  
>
> *From:*delphi-bounces at listserver.123.net.nz
> <mailto:delphi-bounces at listserver.123.net.nz>
> [mailto:delphi-bounces at listserver.123.net.nz] *On Behalf Of *Ross Levis
> *Sent:* Tuesday, October 02, 2012 5:00 PM
> *To:* 'NZ Borland Developers Group - Delphi List'
> *Subject:* [DUG] Unicode help in D7
>
>  
>
> I’m adding a small amount of Unicode support in my D7 app to enable
> opening files where the filenames are in foreign languages.  Currently
> my app can’t even open these files.  I’ve installed an OpenFile dialog
> which provides WideString results.
>
>  
>
> One thing I need is to resolve shortcuts.  I have converted the
> following function which I had for ANSI filenames into Unicode.  Just
> IShellLinkW and TWin32FindDataW changed.
>
>  
>
> *function ResolveShortcut(const LinkPath: WideString): WideString;*
>
> *var*
>
> *ShellLink: IShellLinkW*
>
> *  FindData: TWin32FindDataW;*
>
> *  buff: Array [0..Max_Path-1] of Char;*
>
> *begin*
>
> *  ShellLink := CreateComObject(CLSID_ShellLink) as IShellLinkW;*
>
> *PersistFile := ShellLink as IPersistFile;*
>
> *  if (PersistFile.Load(PWideChar(LinkPath),STGM_READ) = S_OK) and*
>
> *   (ShellLink.Resolve(Application.Handle, SLR_NO_UI) = NOERROR) and*
>
> *   (ShellLink.GetPath(buff,MAX_PATH,FindData,SLGP_UNCPRIORITY)=
> NOERROR) then*
>
> *    Result := buff*
>
> *  else Result := ''*
>
> *end;*
>
>  
>
> But I’m not sure if the buff array should be of WideChar or left as Char.
>
>  
>
> Does MAX_PATH assume wide characters?
>
>  
>
> Thanks,
>
> Ross.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz <mailto:delphi at listserver.123.net.nz>
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz
> <mailto:delphi-request at listserver.123.net.nz> with Subject: unsubscribe
>
>
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at listserver.123.net.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at listserver.123.net.nz with Subject: unsubscribe


-- 
/Fortune/ favours the *brave*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20121003/f3e99490/attachment-0001.html 


More information about the Delphi mailing list