| | |
How to use wifstream to read a unicode file..
![]() |
•
•
Join Date: Dec 2005
Posts: 3
Reputation:
Solved Threads: 0
Hi All,
Currently I am doing one project related to unicode file reading & writing. I got my result using CFile & using WcharToMultibyte,MultiByteToWchar conversion functions. But I have a doubt whether those functions work fine if the unichar is more than 2 bytes.
Now I want to read the file(UTF8,16(BE),16(LE)) using wifstream..
Can anyone help me???
Currently I am doing one project related to unicode file reading & writing. I got my result using CFile & using WcharToMultibyte,MultiByteToWchar conversion functions. But I have a doubt whether those functions work fine if the unichar is more than 2 bytes.
Now I want to read the file(UTF8,16(BE),16(LE)) using wifstream..
Can anyone help me???
•
•
•
•
Originally Posted by WolfPack
unichar can be more than 2 bytes? I thought it was always 2 bytes.
The size of wchar_t is operating system dependent. On MS-Windows wchar_t is defined as unsigned short. *nix computers it is unsigned long. And the UNICODE standards say that they intend to have 64-bit wchr_t.
That becomes a very big problem when attempting to port a UNICODE file between operating systems.
smality: No sure if this will help or not.
•
•
Join Date: Dec 2005
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Ancient Dragon
The size of wchar_t is operating system dependent. On MS-Windows wchar_t is defined as unsigned short. *nix computers it is unsigned long. And the UNICODE standards say that they intend to have 64-bit wchr_t.
That becomes a very big problem when attempting to port a UNICODE file between operating systems.
smality: No sure if this will help or not.
this time i am trying use wistream...i willl read byte by byte......... and after getting the BOM ..then i will read all the bytes for a unichar...but if i get the byte then how to convert it back to unichar to show in textbox or listControl..
Do you have any idea regarding wistream application
thanks..
I don't use c++ streams for UNICODE for the reasons you describe -- its a lot easier to use C's FILE, fopen() in binary mode, fread() and fwrite(). You don't have to worry about conversion that way. That works providing you don't want to transport the file from one operating system to another and you don't want to use another editor such as Notepad.exe to read it.
If you still want to use wfstreams, you can use mbstowcs() to convert from char* to wchar_t*, or wcstombs() to convert the other direction.
If you still want to use wfstreams, you can use mbstowcs() to convert from char* to wchar_t*, or wcstombs() to convert the other direction.
•
•
Join Date: Dec 2005
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Ancient Dragon
If you still want to use wfstreams, you can use mbstowcs() to convert from char* to wchar_t*, or wcstombs() to convert the other direction.
VC compiler is not designed in that way..
Thanks,
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: C++ Graphics (graphics.h)
- Next Thread: complex declarations & other doubts
| Thread Tools | Search this Thread |
ace_thread api array assignment based binary bitmap borland c++ c++endcode c/c++ char class classes code coding compile connect console conversion count delete delete-line deploy desktop developer directshow dll download dynamic dynamiccharacterarray email embedded encryption error file forms fstream function functions game givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream information input int integer java lib linkedlist linker loop looping loops map math mathhomeworkhelp matrix memory multidimensional multiple news node output pointer problem program programming project python random read recursion reference remote reverse richedit rpg string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets






