From Unicode to paths

Vadim Zeitlin vadim at wxwindows.org
Tue May 1 15:19:17 PDT 2007


On Tue, 1 May 2007 22:45:43 +0200 YAP <x112358 at gmail.com> wrote:

Y> If you represent a path for example as a wxString at the higher levels
Y> of the program what is the correct way to convert it.

 If you use wx functions you don't need to convert it at all.

Y> For example for the Linux dlopen is this valid

 For example, you can use wxDynamicLibrary and not care about conversions.

Y>     char szPath[PATH_MAX];
Y> 
Y>     strcpy( szPath, strPath.ToAscii() );
Y>     if ( NULL == ( m_hinst = dlopen( szPath, RTLD_LAZY ) ) ) {
Y>        return false;
Y>    }

 The strcpy() is unnecessary, you can just do "dlopen(strPath.ToAscii())"
directly. Of course, this only works if the path has only ASCII characters.

Y> The docs recommend using wxString::mb_str  will the use of this method
Y> allow for national characters in path also for low level functions as
Y> above.

 The mb_str() method by default returns the representation of wide string
in the current locale. Whether the function you call expects this or
something else (like a string always encoded in UTF-8 independently of
locale) is another question.

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/





More information about the wx-users mailing list