473,586 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using streams for opening files in unicode.

I need to know how can I open a file which is named using UTF-16
encoding in unicode. I am desperately trying to open the file using the
wofstream typedef, but even it takes the parameter as const char*, I
tried converting the filename from UTF16 to UTF8 encoding, wofstream
does not seem to work with that.
What I gather is that streams internally use fopen for opening up a
file, I could not find any way for passing a file descriptor to the
stream class to initialize it, basically trying to use a _wfopen to get
a file descriptor, but how can I pass it to a stream to initialize it
to it?

Kindly Note: I have to use streams for the same, it is a restriction in
the current architecture.

Please do let me know of any other way .

Gangs.

Jan 9 '07 #1
1 1946

gangs wrote:
I need to know how can I open a file which is named using UTF-16
encoding in unicode. I am desperately trying to open the file using the
wofstream typedef, but even it takes the parameter as const char*, I
tried converting the filename from UTF16 to UTF8 encoding, wofstream
does not seem to work with that.
What I gather is that streams internally use fopen for opening up a
file, I could not find any way for passing a file descriptor to the
stream class to initialize it, basically trying to use a _wfopen to get
a file descriptor, but how can I pass it to a stream to initialize it
to it?

Kindly Note: I have to use streams for the same, it is a restriction in
the current architecture.
There isn't any simple way of doing this. You need to convert the
UTF-16 sequence into the correct code page that the application is
running. This code page may not of course be able to handle the
characters at all in which case opening the file is going to be hard.

If you have OS specific ways of getting a lower level file handle then
you could write your own IO stream buffer. It's not as hard as it may
at first seem.

I'm guessing that you're doing this on Windows. If you are, and you do
write your own stream classes that can handle full Windows file names
then please release the implementation - I'm sure many people would be
interested in it (including me). I'll swap you our TCP/IP stream
classes :-)
K

Jan 9 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
6579
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am...
6
1884
by: syed javid | last post by:
hi all, I am getting an error when i process 1 MB txt file using StreamReader and i am reading char by char using streamReader.Read() method at some point it is throwing an exception System.ComponentModel.win32Exception:The handle is invalid. Any help for this problem or any kind of informaiton to process large files the file size can be...
5
2851
by: Earl Teigrob | last post by:
My company sells software and wants to provide downloadable product. Some of these downloads will be full CD's of over 550M I had everything working fine using Response.filewrite() but when we tested it with large files, it blew up. (crashed the server, well documented problem) I can download a file just fine if I just point to the...
10
12280
by: Roger Withnell | last post by:
I'm using ASP, VBScript and SQL Server. I'm also using UTF-8 character set and so my codepage is 65001 and SQL Server datatype nvarchar. I can insert unicode characters correctly into the database table using INSERT.... (field1) ...VALUES ......... (N'Characters'). How do I do this using Rs.Update viz-a-viz:
18
6704
by: mollyf | last post by:
I just installed SQL Server 2005 on my PC (the developer's edition) yesterday. I have some scripts written by one of my coworkers to create some tables and stored procedures in a database that I've already created on my computer. Whenever I go to open the script file (whose icon shows that it's a SQL Server Query File and I've got the file...
4
2533
by: William Ahern | last post by:
Has it ever been proposed or posited within any C committee to define or discuss (in a standard's document) the transformation of Unicode text I/O according to a Unicode Normalization Form (assuming a locale which employs a Unicode representation)? Is such a capability implicit? The notion exists and seems to work well for line/record...
3
3195
by: Kirit Sælensminde | last post by:
>From thread http://groups.google.com/group/comp.lang.c++/browse_thread/thread/79d767efa42df516 "P.J. Plauger" <p...@dinkumware.comwrites: I'll take this at face value and I'll have to suppose that I don't understand what the streams should do. I guess then the root of my problem is my expectation that if I use a std::ofstream it will...
0
252
by: gangs | last post by:
I need to know how can I open a file which is stored using UTF-16 encoding in unicode. I am desperately trying to open the file using the wofstream typedef, but even it takes the parameter as const char*, I tried converting the filename from UTF16 to UTF8 encoding, wofstream does not seem to work with that. What I gather is that streams...
4
3668
by: Teresa Masino | last post by:
We have set up a couple of SQL Server 2005 systems and I have found that the format of the ERRORLOG files and the SQL Agent's log files are Unicode or some format that findstr cannot parse properly. "find" parses them fine, but it doesn't have the capabilities that I need -- specifically, I can't search for multiple strings in one search. ...
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3865
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.