Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: OpenDialog and standard c++ function "open" problem with internationalchars



Permlink Replies: 2 - Last Post: Oct 4, 2016 3:25 PM Last Post By: Timur Tekil
Timur Tekil

Posts: 25
Registered: 12/25/13
OpenDialog and standard c++ function "open" problem with internationalchars
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 4, 2016 1:57 PM
I use a TOpenDialog object to make user select files.And then open the first file in binary mode and wrote something to file.I wrote this:

OpenDialog1->Execute();
TStringDynArray strarray1;
strarray1=OpenDialog1->Files->ToStringArray();
std::fstream file1;
file1.open((strarray1[0].w_str()),ios::binary | ios::in);
...


If I select a file which has English characters only and doesn't have international characters(Turkish characters) , the code works without problem. But if the file has international characters, file1.open can't open the file.

I am sure there are C++ Builder-specific I/O functions to work with international characters, Unicode supporting functions but I wonder if it is possible to use standard C++ I/O functions instead or with slight variations(for example, instead of using open function, an alternative "uopen" function).

Edited by: Timur Tekil on Oct 4, 2016 2:13 PM
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: OpenDialog and standard c++ function "open" problem withinternationalchars [Edit]
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 4, 2016 3:20 PM   in response to: Timur Tekil in response to: Timur Tekil
Timur wrote:

If I select a file which has English characters only and doesn't have
international characters(Turkish characters) , the code works without
problem. But if the file has international characters, file1.open
can't open the file.

Known bug for many versions, still not fixed as of Seattle (haven't checked
Berlin yet):

[Dinkumware x86, x64] wchar_t* version of fstream cannot open Unicode file
name
http://qc.embarcadero.com/wc/qcmain.aspx?d=111462
https://quality.embarcadero.com/browse/RSP-16020

Basically, when you pass a Unicode filename to std::fstream, the filename
gets converted to the OS's current Ansi codepage before opening the file.
That conversion is losing your Turkish characters.

--
Remy Lebeau (TeamB)
Timur Tekil

Posts: 25
Registered: 12/25/13
Re: OpenDialog and standard c++ function "open" problem with internationalchars
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 4, 2016 3:25 PM   in response to: Timur Tekil in response to: Timur Tekil
Thanks for your answer Remy :)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02