Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-09-03 Thread Konstantin Tokarev
03.09.2013, 08:00, "baneyue" : > On Fri, Aug 30, 2013 at 03:08:42PM -0400, Michael Jackson wrote: > >>  I have a large code base that we are migrating to more fully utilize Qt >> classes. Many places in the code have lines like the following: >> >>  std::string path("/path/to/foo.txt"); >>  FILE

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-09-02 Thread baneyue
On Fri, Aug 30, 2013 at 03:08:42PM -0400, Michael Jackson wrote: > I have a large code base that we are migrating to more fully utilize Qt > classes. Many places in the code have lines like the following: > > std::string path("/path/to/foo.txt"); > FILE* f = fopen(path.c_str(), "wb"); > > If the

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-09-01 Thread Konstantin Tokarev
30.08.2013, 23:09, "Michael Jackson" : > I have a large code base that we are migrating to more fully utilize Qt > classes. Many places in the code have lines like the following: > > std::string path("/path/to/foo.txt"); > FILE* f = fopen(path.c_str(), "wb"); > > If the "path" variable is now de

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Thiago Macieira
On sábado, 31 de agosto de 2013 17:27:55, Michael Jackson wrote: > Well, unfortunately I can not remove HDF5 as or entire file format is based > on it. So with that limiting factor in place and knowing that I may have a > file path coming from a standard Open/Save Dialog how would _you_ handle > th

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Michael Jackson
On Aug 31, 2013, at 12:51 PM, Thiago Macieira wrote: >> >> 3) We use the HDF5 (www.hdfgroup.org) to store files. The entire interface >> is "C" and uses char* to get strings into and out the file when needed. Of >> all the discussion going on this is the part that worries me the most. Do I >> u

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Thiago Macieira
On sábado, 31 de agosto de 2013 11:41:20, Till Oliver Knoll wrote: > Am 31.08.2013 um 03:00 schrieb Thiago Macieira : > > > > > > As I said in the other email, if you're going to run this code on Windows, > > you should stop using fopen and iostreams. > > Out of curiosity (and since I am a "

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Thiago Macieira
On sábado, 31 de agosto de 2013 16:31:19, Syam Krishnan wrote: > > Even “simple English” may contain characters not encodable in Latin 1… > > > > As I've just proven > > Oh.. by 'simple English', I meant basic ASCII.. Anyway, if the original > string contained anything other than ASCII printable

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Thiago Macieira
On sábado, 31 de agosto de 2013 09:26:23, Michael Jackson wrote: > As the original poster, thanks everyone for their input. Let me add some > more context to where these "strings" maybe coming from. > > 1) We have constants defined in headers using US ASCII Only Characters such > as the following:

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Constantin Makshin
For ASCII-only hardcoded constant strings it's better to use QLatin1String because of its significantly lower overhead compared to QString (no additional memory [de]allocations and copying, it uses the original 'const char*' as its contents). For storing strings I'd recommend using UTF-8 because i

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Michael Jackson
On Aug 30, 2013, at 11:42 PM, Thiago Macieira wrote: > On sexta-feira, 30 de agosto de 2013 19:47:48, Syam wrote: >> On 31-Aug-2013 6:28 AM, "Thiago Macieira" wrote: >>> On sexta-feira, 30 de agosto de 2013 19:17:58, Scott Aron Bloom wrote: I use toUtf8()... Though it wouldn't surprise me

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Syam Krishnan
On 08/31/2013 09:12 AM, Thiago Macieira wrote: > On sexta-feira, 30 de agosto de 2013 19:47:48, Syam wrote: > >> Am I right here? Of course, the assumption is that the original QString is >> simple English text. > Even “simple English” may contain characters not encodable in Latin 1… > > As I've ju

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-31 Thread Jonathan Greig
I'm also interested in why fopen shouldn't be used on Windows. The libembroidery code I work with is C89, uses fopen all over the place, and is cross-platform. The only place it doesn't work that I have tried is on arduino(which appears to have fdevopen equivalent but I'm unsure of whether that is

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Thiago Macieira
On sexta-feira, 30 de agosto de 2013 19:47:48, Syam wrote: > On 31-Aug-2013 6:28 AM, "Thiago Macieira" wrote: > > On sexta-feira, 30 de agosto de 2013 19:17:58, Scott Aron Bloom wrote: > > > I use toUtf8()... Though it wouldn't surprise me if Thiago scolds me > > > for it > > > > If you're on Unix

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Syam
On 31-Aug-2013 6:28 AM, "Thiago Macieira" wrote: > > On sexta-feira, 30 de agosto de 2013 19:17:58, Scott Aron Bloom wrote: > > I use toUtf8()... Though it wouldn't surprise me if Thiago scolds me for it > > If you're on Unix, that's fine. It's fine because if your Unix system uses a > locale diff

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Thiago Macieira
On sexta-feira, 30 de agosto de 2013 16:00:17, Michael Jackson wrote: > Thanks for the nice explanations. In some places we use FILE*, some > iostream, some custom file. There are other places that we use the HDF5 > library and it is "C" based and takes "char*" for all of its "string" type > argume

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Thiago Macieira
On sexta-feira, 30 de agosto de 2013 19:17:58, Scott Aron Bloom wrote: > I use toUtf8()... Though it wouldn't surprise me if Thiago scolds me for it If you're on Unix, that's fine. It's fine because if your Unix system uses a locale different from UTF-8, you *really* should be scolded :-) If you

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Michael Jackson
On Aug 30, 2013, at 3:45 PM, Andreas Pakulat wrote: > Hi, > > On Fri, Aug 30, 2013 at 9:08 PM, Michael Jackson > wrote: > I have a large code base that we are migrating to more fully utilize Qt > classes. Many places in the code have lines like the following: > > std::string path("/path/to/

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Paul Miller
On 8/30/13 2:08 PM, Michael Jackson wrote: > I have a large code base that we are migrating to more fully utilize Qt > classes. Many places in the code have lines like the following: > > std::string path("/path/to/foo.txt"); > FILE* f = fopen(path.c_str(), "wb"); > > If the "path" variable is now

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Constantin Makshin
According to the documentation, toStdString() converts characters using toAscii(). That means non-ASCII characters (ones with codes above 127) will get messed up unless you explicitly set codec by calling QTextCodec::setCodecForCStrings(). On 08/30/2013 11:33 PM, Michael Jackson wrote: > So maybe

[Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Michael Jackson
I have a large code base that we are migrating to more fully utilize Qt classes. Many places in the code have lines like the following: std::string path("/path/to/foo.txt"); FILE* f = fopen(path.c_str(), "wb"); If the "path" variable is now declared as a QString which QString method would be me

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Andreas Pakulat
Hi, On Fri, Aug 30, 2013 at 9:08 PM, Michael Jackson wrote: > I have a large code base that we are migrating to more fully utilize Qt > classes. Many places in the code have lines like the following: > > std::string path("/path/to/foo.txt"); > FILE* f = fopen(path.c_str(), "wb"); > > If the "path

Re: [Interest] Converting std::string.c_str() code to use QString methods

2013-08-30 Thread Scott Aron Bloom
erest-bounces+scott.bloom=onshorecs@qt-project.org [mailto:interest-bounces+scott.bloom=onshorecs@qt-project.org] On Behalf Of Michael Jackson Sent: Friday, August 30, 2013 12:09 PM To: interest@qt-project.org Subject: [Interest] Converting std::string.c_str() code to use QString methods I h