473,326 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

MultiByteToWideChar converting %[code]... erf...

Hi ppl, just a quick question...

I need to use "MultiByteToWideChar(stuff)" to convert a char[MAX_PATH] to
unicode, so that OleLoadPicturePath can get the image files i want, and load
it into a HBITMAP, etc... I'm having trouble when my char[MAX_PATH] has a
%[code], for example:

"C:\Image\my image.bmp" is translated to the unicode equivalent, without
problems

"C:\Image\my%20image.bmp" is translated to the unicode equivalent of
"C:\Image\my image.bmp"

So i want to send in a path string to MultiByteToWideChar(stuff) which might
have %[code] in it, and I want MultiByteToWideChar() to ignor the %[code],
in other words:

something() {
char sPath[MAX_PATH];
OLECHAR sUniPath[MAX_PATH + 1];

// This is the first (and working) string
strcpy(sPath, "C:\image file.bmp");
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sPath, -1, sUniPath,
MAX_PATH);
// sUniPath is the unicode for "C:\image file.bmp"
}

something() {
char sPath[MAX_PATH];
OLECHAR sUniPath[MAX_PATH + 1];

// This is the second (and NOT working) string
strcpy(sPath, "C:\image%20file.bmp");
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sPath, -1, sUniPath,
MAX_PATH);
// sUniPath is the unicode for "C:\image file.bmp"... erf... I want it
to be the unicode for "C:\image%20file.bmp"...
}

I've tried to read up at msdn on MultiByteToWideChar, but I couldn't find
the params to do this (or just can't read the docs as well as some of you
people ~.0 ). If any of you know what i'm doing wrong, or know of a
different call to convert to unicode, please give me the info ;) I've hurd
that MultiByteToWideChar is the subject of overflows, so maybe finding a
different call would be best. Thanks in advance ;)
Jul 22 '05 #1
7 6376
"Robert Diamond" <-r***@anti.spam.com> wrote in message
news:IW******************@news04.bloor.is.net.cabl e.rogers.com
Hi ppl, just a quick question...

I need to use "MultiByteToWideChar(stuff)" to convert a
char[MAX_PATH] to unicode, so that OleLoadPicturePath can get the
image files i want, and load it into a HBITMAP, etc... I'm having
trouble when my char[MAX_PATH] has a %[code], for example:

"C:\Image\my image.bmp" is translated to the unicode equivalent,
without problems

"C:\Image\my%20image.bmp" is translated to the unicode equivalent of
"C:\Image\my image.bmp"

So i want to send in a path string to MultiByteToWideChar(stuff)
which might have %[code] in it, and I want MultiByteToWideChar() to
ignor the %[code], in other words:

something() {
char sPath[MAX_PATH];
OLECHAR sUniPath[MAX_PATH + 1];

// This is the first (and working) string
strcpy(sPath, "C:\image file.bmp");
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sPath, -1, sUniPath,
MAX_PATH);
// sUniPath is the unicode for "C:\image file.bmp"
}

something() {
char sPath[MAX_PATH];
OLECHAR sUniPath[MAX_PATH + 1];

// This is the second (and NOT working) string
strcpy(sPath, "C:\image%20file.bmp");
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sPath, -1, sUniPath,
MAX_PATH);
// sUniPath is the unicode for "C:\image file.bmp"... erf... I
want it to be the unicode for "C:\image%20file.bmp"...
}


You have attempted to post this to four newsgroups, two of which don't
exist. It is off-topic in this one (comp.lang.c++) since it is Microsoft
specific. You might try, e.g.,

microsoft.public.vc.language
or
comp.os.ms-windows.programmer.win32

I ran your code out of interest and the % came through fine. The error I
found was in your backslash. A backslash is entered into code with a double
backslash, i.e., '\\'. The first three characters in

"C:\image%20file.bmp"

are 'C', ':' and '\i'. Since there is no '\i' character, this produces
undefined behaviour. You should use:

"C:\\image%20file.bmp"
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #2
"Robert Diamond" <-r***@anti.spam.com> wrote in message
news:IW******************@news04.bloor.is.net.cabl e.rogers.com
Hi ppl, just a quick question...

I need to use "MultiByteToWideChar(stuff)" to convert a
char[MAX_PATH] to unicode, so that OleLoadPicturePath can get the
image files i want, and load it into a HBITMAP, etc... I'm having
trouble when my char[MAX_PATH] has a %[code], for example:

"C:\Image\my image.bmp" is translated to the unicode equivalent,
without problems

"C:\Image\my%20image.bmp" is translated to the unicode equivalent of
"C:\Image\my image.bmp"

So i want to send in a path string to MultiByteToWideChar(stuff)
which might have %[code] in it, and I want MultiByteToWideChar() to
ignor the %[code], in other words:

something() {
char sPath[MAX_PATH];
OLECHAR sUniPath[MAX_PATH + 1];

// This is the first (and working) string
strcpy(sPath, "C:\image file.bmp");
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sPath, -1, sUniPath,
MAX_PATH);
// sUniPath is the unicode for "C:\image file.bmp"
}

something() {
char sPath[MAX_PATH];
OLECHAR sUniPath[MAX_PATH + 1];

// This is the second (and NOT working) string
strcpy(sPath, "C:\image%20file.bmp");
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sPath, -1, sUniPath,
MAX_PATH);
// sUniPath is the unicode for "C:\image file.bmp"... erf... I
want it to be the unicode for "C:\image%20file.bmp"...
}


You have attempted to post this to four newsgroups, two of which don't
exist. It is off-topic in this one (comp.lang.c++) since it is Microsoft
specific. You might try, e.g.,

microsoft.public.vc.language
or
comp.os.ms-windows.programmer.win32

I ran your code out of interest and the % came through fine. The error I
found was in your backslash. A backslash is entered into code with a double
backslash, i.e., '\\'. The first three characters in

"C:\image%20file.bmp"

are 'C', ':' and '\i'. Since there is no '\i' character, this produces
undefined behaviour. You should use:

"C:\\image%20file.bmp"
--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #3

"John Carson" <do***********@datafast.net.au> wrote in message
news:40********@usenet.per.paradox.net.au...

You have attempted to post this to four newsgroups, two of which don't
exist. It is off-topic in this one (comp.lang.c++) since it is Microsoft
specific. You might try, e.g.,

microsoft.public.vc.language
or
comp.os.ms-windows.programmer.win32
The two that don't exist, exist on my nntp server...

I did post to two m$ vc newgroups
I ran your code out of interest and the % came through fine. The error I
found was in your backslash. A backslash is entered into code with a double backslash, i.e., '\\'. The first three characters in

"C:\image%20file.bmp"

are 'C', ':' and '\i'. Since there is no '\i' character, this produces
undefined behaviour. You should use:

"C:\\image%20file.bmp"
I forgot to add the escape code in the post... not in my code....

the %[code] does come through... it comes through decoded... ie:
"something\\some%20thing" turns into unicode for "something\\some thing".
Notice the space... the %[code] was decoded, and i don't want it to... i
want "something\\some%20thing" to turn into unicode for
"something\\some%20thing" (Notice the "%20" and not the ' ' <space> char).

--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


you forgot to reply to the new group i specified... ie: n00b, know before
you flame, and if you flame, flame to the news group i specified as the
reply-to group!
Jul 22 '05 #4

"John Carson" <do***********@datafast.net.au> wrote in message
news:40********@usenet.per.paradox.net.au...

You have attempted to post this to four newsgroups, two of which don't
exist. It is off-topic in this one (comp.lang.c++) since it is Microsoft
specific. You might try, e.g.,

microsoft.public.vc.language
or
comp.os.ms-windows.programmer.win32
The two that don't exist, exist on my nntp server...

I did post to two m$ vc newgroups
I ran your code out of interest and the % came through fine. The error I
found was in your backslash. A backslash is entered into code with a double backslash, i.e., '\\'. The first three characters in

"C:\image%20file.bmp"

are 'C', ':' and '\i'. Since there is no '\i' character, this produces
undefined behaviour. You should use:

"C:\\image%20file.bmp"
I forgot to add the escape code in the post... not in my code....

the %[code] does come through... it comes through decoded... ie:
"something\\some%20thing" turns into unicode for "something\\some thing".
Notice the space... the %[code] was decoded, and i don't want it to... i
want "something\\some%20thing" to turn into unicode for
"something\\some%20thing" (Notice the "%20" and not the ' ' <space> char).

--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)


you forgot to reply to the new group i specified... ie: n00b, know before
you flame, and if you flame, flame to the news group i specified as the
reply-to group!
Jul 22 '05 #5
Robert Diamond wrote:

you forgot to reply to the new group i specified... ie: n00b, know before
you flame, and if you flame, flame to the news group i specified as the
reply-to group!


Being rude (first by OT posting + mass cross-posting, then with this) is
a poor way to get help. Goodbye.

*PLONK*

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #6
Robert Diamond wrote:

you forgot to reply to the new group i specified... ie: n00b, know before
you flame, and if you flame, flame to the news group i specified as the
reply-to group!


Being rude (first by OT posting + mass cross-posting, then with this) is
a poor way to get help. Goodbye.

*PLONK*

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #7
"Robert Diamond" <-r***@anti.spam.com> wrote in message
news:M2******************@news04.bloor.is.net.cabl e.rogers.com


the %[code] does come through... it comes through decoded... ie:
"something\\some%20thing" turns into unicode for "something\\some
thing". Notice the space... the %[code] was decoded, and i don't want
it to... i want "something\\some%20thing" to turn into unicode for
"something\\some%20thing" (Notice the "%20" and not the ' ' <space>
char).
It doesn't come through decoded for me. It comes through with the %20
intact. Since you are apparently retyping your code into the post rather
than copying and pasting, it is anyone's guess what is going wrong. Perhaps
the conversion is working but the method that you are using to display the
string is what is causing the space. But that is just a guess.
you forgot to reply to the new group i specified... ie: n00b, know
before you flame, and if you flame, flame to the news group i
specified as the reply-to group!


You have a rather liberal definition of flame. I initially attempted to post
my reply using the default reply procedure, which meant posting to
microsoft.public.vc, as you had specified. I got an error and so manually
modified the reply field to a newsgroup that I knew did exist.

If I connect directly to the microsoft news server, msnews.microsoft.news,
using Outlook Express, then microsoft.public.vc is *not* listed. It is also
not on the news server of my ISP. I have, upon receiving your reply, found
it on another news server (I still can't find alt.comp.lang.c++ anywhere,
though there is an alt.comp.lang.c).

Since you raise the issue of etiquette, I would point out that redirecting
all replies to a single newsgroup most convenient to yourself is a
discourtesy to others since it obliges them to switch to your preferred
newsgroup in order to follow the thread. Cross posting to multiple
newsgroups in the first place is a practice that is discouraged, even more
so when your post is off topic in some of them.

--
John Carson
1. To reply to email address, remove donald
2. Don't reply to email address (post here instead)

Jul 22 '05 #8

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

Similar topics

7
by: Robert Diamond | last post by:
Hi ppl, just a quick question... I need to use "MultiByteToWideChar(stuff)" to convert a char to unicode, so that OleLoadPicturePath can get the image files i want, and load it into a HBITMAP,...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
2
by: groups | last post by:
I have a C# application which needs to convert MultiByte strings to Unicode. However, I cannot get MultiByteToWideChar to behave as expected within ..net. I have declared it as follows: ...
3
by: Parvesh | last post by:
hi, I am using a webservice which Returns the Result in an XML string, The XML response i get i svery cumbersome to parse, But if i could convert it to the Corresponding Class using the...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
7
by: Coleen | last post by:
Does anyone have any good detailed information on the conversion process? We are in the process of converting 2 projects from 2003 to 2005 and have some conversion errors that I can not find...
5
by: Swandog46 | last post by:
I hope this is the appropriate forum for this question. I apologize if it is not. Consider the following code snippet: DWORD length; PCHAR buf = new CHAR; strcpy( buf, "HelloWorld" );...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.