473,772 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MultiByteToWide Char converting %[code]... erf...

Hi ppl, just a quick question...

I need to use "MultiByteToWid eChar(stuff)" to convert a char[MAX_PATH] to
unicode, so that OleLoadPictureP ath 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\m y image.bmp" is translated to the unicode equivalent, without
problems

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

So i want to send in a path string to MultiByteToWide Char(stuff) which might
have %[code] in it, and I want MultiByteToWide Char() 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");
MultiByteToWide Char(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%20fil e.bmp");
MultiByteToWide Char(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%20fil e.bmp"...
}

I've tried to read up at msdn on MultiByteToWide Char, 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 MultiByteToWide Char is the subject of overflows, so maybe finding a
different call would be best. Thanks in advance ;)
Jul 22 '05 #1
7 6439
"Robert Diamond" <-r***@anti.spam. com> wrote in message
news:IW******** **********@news 04.bloor.is.net .cable.rogers.c om
Hi ppl, just a quick question...

I need to use "MultiByteToWid eChar(stuff)" to convert a
char[MAX_PATH] to unicode, so that OleLoadPictureP ath 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\m y image.bmp" is translated to the unicode equivalent,
without problems

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

So i want to send in a path string to MultiByteToWide Char(stuff)
which might have %[code] in it, and I want MultiByteToWide Char() 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");
MultiByteToWide Char(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%20fil e.bmp");
MultiByteToWide Char(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%20fil e.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.publi c.vc.language
or
comp.os.ms-windows.program mer.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%20fil e.bmp"

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

"C:\\image%20fi le.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******** **********@news 04.bloor.is.net .cable.rogers.c om
Hi ppl, just a quick question...

I need to use "MultiByteToWid eChar(stuff)" to convert a
char[MAX_PATH] to unicode, so that OleLoadPictureP ath 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\m y image.bmp" is translated to the unicode equivalent,
without problems

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

So i want to send in a path string to MultiByteToWide Char(stuff)
which might have %[code] in it, and I want MultiByteToWide Char() 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");
MultiByteToWide Char(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%20fil e.bmp");
MultiByteToWide Char(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%20fil e.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.publi c.vc.language
or
comp.os.ms-windows.program mer.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%20fil e.bmp"

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

"C:\\image%20fi le.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.par adox.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.publi c.vc.language
or
comp.os.ms-windows.program mer.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%20fil e.bmp"

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

"C:\\image%20fi le.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\\som e%20thing" turns into unicode for "something\\som e thing".
Notice the space... the %[code] was decoded, and i don't want it to... i
want "something\\som e%20thing" to turn into unicode for
"something\\som e%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.par adox.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.publi c.vc.language
or
comp.os.ms-windows.program mer.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%20fil e.bmp"

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

"C:\\image%20fi le.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\\som e%20thing" turns into unicode for "something\\som e thing".
Notice the space... the %[code] was decoded, and i don't want it to... i
want "something\\som e%20thing" to turn into unicode for
"something\\som e%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******** **********@news 04.bloor.is.net .cable.rogers.c om


the %[code] does come through... it comes through decoded... ie:
"something\\som e%20thing" turns into unicode for "something\\som e
thing". Notice the space... the %[code] was decoded, and i don't want
it to... i want "something\\som e%20thing" to turn into unicode for
"something\\som e%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.publi c.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.microsof t.news,
using Outlook Express, then microsoft.publi c.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
543
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, etc... I'm having trouble when my char has a %, for example: "C:\Image\my image.bmp" is translated to the unicode equivalent, without problems
8
5744
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 output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
5
2527
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 applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on instead and converted one of the virtual roots that is a seperate
3
2427
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 myself. Any help much appreciated.
2
11863
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: static extern Int32 MultiByteToWideChar( UInt32 codePage, UInt32 dwFlags,
3
2473
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 System.Xml.Serialization, i think that can solve my problem. But i tried using the Deserialize method for converting the XML to the Corresponding Object, neither i get error nor i get any luck for converting it to Object.
12
3191
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
3194
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 get public members but not protected, private, static members"
7
2501
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 answers to. First, we have a lot of UserControls. I am getting the error "Type uc_mc_btn_footer is not defined." where uc_mc_btn_footer is the name of the UserControl. Also, on almost all of our UserControls the conversion has remmed out all my code...
5
6821
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" ); printf( "*(&length - 1) = 0x%x\n", *(&length - 1) ); length = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 );
0
9621
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6716
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.