473,668 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wide string problem ...

Hi

I'm having major problems writing a function that converts a long
value into a wide string !!! I'm more than likely going round in
circles and not seeing the wood for the trees now but am frustreated
just the same.

My function looks like this:

std::wstring CReportCreator: :SetEmpricalDef aults(const udtLONG&
udtValue)
{
wstring ret = L"";
ret = Utilities::Long ToStdWString(ud tValue.lngValue );
return ret;

}
LongToStdWStrin g() is used elsewhere and works ok.

My call is this:

wstring strOut = SetEmpricalDefa ults(300L);

and then:

WCHAR xml[255];
wsprintf(xml, L"<X><a=\"%s \" /></X>", strOut);

wsprintf throws a scalar deleting desctructor exception.

when i debug strOut show as "*300".

does anyone know what the '*' represents at the beginning of the 300 ?

does anyone know of a function that will return a unicode string from
a long ? so far i've tried stringstreams and _ltow but always get the
* in front of the 300 and wsprintf throws an exception ...

many thanks

Mar 12 '07 #1
19 3643
On Mar 12, 5:27 pm, "SteveB" <s...@thebretts .co.ukwrote:
Hi

I'm having major problems writing a function that converts a long
value into a wide string !!! I'm more than likely going round in
circles and not seeing the wood for the trees now but am frustreated
just the same.

My function looks like this:

std::wstring CReportCreator: :SetEmpricalDef aults(const udtLONG&
udtValue)
{
wstring ret = L"";
ret = Utilities::Long ToStdWString(ud tValue.lngValue );
return ret;

}

LongToStdWStrin g() is used elsewhere and works ok.

My call is this:

wstring strOut = SetEmpricalDefa ults(300L);

and then:

WCHAR xml[255];
wsprintf(xml, L"<X><a=\"%s \" /></X>", strOut);
wsprintf(xml, L"<X><a=\"%s \" /></X>", strOut.data()); //Should be
this?
>
wsprintf throws a scalar deleting desctructor exception.

when i debug strOut show as "*300".

does anyone know what the '*' represents at the beginning of the 300 ?

does anyone know of a function that will return a unicode string from
a long ? so far i've tried stringstreams and _ltow but always get the
* in front of the 300 and wsprintf throws an exception ...

many thanks

Mar 12 '07 #2
* SteveB:
Hi

I'm having major problems writing a function that converts a long
value into a wide string !!! I'm more than likely going round in
circles and not seeing the wood for the trees now but am frustreated
just the same.

My function looks like this:

std::wstring CReportCreator: :SetEmpricalDef aults(const udtLONG&
udtValue)
{
wstring ret = L"";
ret = Utilities::Long ToStdWString(ud tValue.lngValue );
return ret;

}

Just a style issue, but make that

{
return Utilities::Long ToStdWString(ud tValue.lngValue );
}
LongToStdWStrin g() is used elsewhere and works ok.
If you say so.

My call is this:

wstring strOut = SetEmpricalDefa ults(300L);

and then:

WCHAR xml[255];
wsprintf(xml, L"<X><a=\"%s \" /></X>", strOut);

wsprintf throws a scalar deleting desctructor exception.
Yes, passing a non-POD class type object to "..." is Undefined Behavior.

It's unclear why you're trying to copy the string to a fixed size buffer.

when i debug strOut show as "*300".

does anyone know what the '*' represents at the beginning of the 300 ?
Depends on your debugger if it's not part of the textual string value.
does anyone know of a function that will return a unicode string from
a long ?
You stated above, "LongToStdWStri ng() is used elsewhere and works ok".
so far i've tried stringstreams
The wide string stream support in g++ for Windows is lacking; perhaps
that's the compiler you're using?

and _ltow
Non-standard.

but always get the * in front of the 300
Mostly irrelevant.

and wsprintf throws an exception ...
If this is from the code shown above, then see above.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 12 '07 #3
On 12 Mar, 09:59, "mimi" <cainiaodelixi. ..@gmail.comwro te:
On Mar 12, 5:27 pm, "SteveB" <s...@thebretts .co.ukwrote:
Hi
I'm having major problems writing a function that converts a long
value into a wide string !!! I'm more than likely going round in
circles and not seeing the wood for the trees now but am frustreated
just the same.
My function looks like this:
std::wstring CReportCreator: :SetEmpricalDef aults(const udtLONG&
udtValue)
{
wstring ret = L"";
ret = Utilities::Long ToStdWString(ud tValue.lngValue );
return ret;
}
LongToStdWStrin g() is used elsewhere and works ok.
My call is this:
wstring strOut = SetEmpricalDefa ults(300L);
and then:
WCHAR xml[255];
wsprintf(xml, L"<X><a=\"%s \" /></X>", strOut);

wsprintf(xml, L"<X><a=\"%s \" /></X>", strOut.data()); //Should be
this?


wsprintf throws a scalar deleting desctructor exception.
when i debug strOut show as "*300".
does anyone know what the '*' represents at the beginning of the 300 ?
does anyone know of a function that will return a unicode string from
a long ? so far i've tried stringstreams and _ltow but always get the
* in front of the 300 and wsprintf throws an exception ...
many thanks- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
many thanks

Mar 12 '07 #4
Alf I'm sure you're a clever guy but I really just asked a question.
The one line answer above was just fine.
Mar 13 '07 #5
* SteveB:
Alf I'm sure you're a clever guy but I really just asked a question.
The one line answer above was just fine.
Please quote relevant context.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 13 '07 #6
* Alf P. Steinbach:
* SteveB:
>Alf I'm sure you're a clever guy but I really just asked a question.
The one line answer above was just fine.

Please quote relevant context.
I mean, I'm not into guessing games: if you want help, be clear.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 13 '07 #7
On 13 Mar, 14:08, "Alf P. Steinbach" <a...@start.now rote:
* Alf P. Steinbach:
* SteveB:
Alf I'm sure you're a clever guy but I really just asked a question.
The one line answer above was just fine.
Please quote relevant context.

I mean, I'm not into guessing games: if you want help, be clear.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
i wasn't posting to get a lecture in how to phrase my questions alf.

it was clear enough for someone else to aswer.

i think you need to get over yourself.

Mar 16 '07 #8
On 16 Mar., 13:39, "SteveB" <s...@thebretts .co.ukwrote:
i think you need to get over yourself.
And I think you need to learn to behave yourself. Alf gave you lots of
valuable info. Being rude is about the silliest response imaginable.

/Peter

Mar 16 '07 #9
On 16 Mar, 13:08, "peter koch" <peter.koch.lar ...@gmail.comwr ote:
On 16 Mar., 13:39, "SteveB" <s...@thebretts .co.ukwrote:i think you need to get over yourself.

And I think you need to learn to behave yourself. Alf gave you lots of
valuable info. Being rude is about the silliest response imaginable.

/Peter
i wasn't being rude peter. mimi answered my question without needing
to dismantle the post and split hairs. my post was directed at the
community and was just at alf. if you read the reply he doesn't really
contribute anything at all. all i'm saying is that if he dopesn't know
the answer where is the benefit of his one hair splitters ? and the be
honest i did look at a few of alfs other posts before i commented.

Mar 16 '07 #10

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

Similar topics

3
2642
by: Jonathan Mcdougall | last post by:
I started using boost's filesystem library a couple of days ago. In its FAQ, it states "Wide-character names would provide an illusion of portability where portability does not in fact exist. Behavior would be completely different on operating systems (Windows, for example) that support wide-character names, than on systems which don't (POSIX). Providing functionality that appears to provide portability but in fact
15
2655
by: Steve | last post by:
Hi, I've been charged with investigating the possibilities of internationalizing our C++ libraries. std::strings are used all over the place, and unfortunately a mixture of isalpha,isdigit,etc. functions from the C library and C++ locale stuff. To fully embrace i18n I'm wondering if we have to fully make the switch to everything being wide ( wstring, wcin, wcout, wide streams, etc.)
11
5203
by: Roger Leigh | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The program listed below demonstrates the use of wcsftime() and std::time_put<wchar_t> which is a C++ wrapper around it. (I know this isn't C; but the "problem" lies in the C library implementation of wcsftime()). I'm not sure if this is a platform-dependent feature or part of the C standard. I've compiled with GCC 3.4.3 on GNU/Linux, and run in an en_GB UTF-8
1
3156
by: ajay.sonawane | last post by:
How can I find the wheather the occurance substring is main string in wide char provided that the compasion should be case insensitive.
1
2317
by: jjf | last post by:
Do Standard C's wide characters and wide strings require absolutely that each character be stored in a single wchar_t, or can characters be "multi-wchar_t" in the same way that they can be multibyte? Is it a requirement that the number of wchar_t's in a string is the same as the number of characters in the string (give or take the terminal null character)? The particular case I'm puzzling over is whether or not it is conforming for an...
8
11870
by: Brand Bogard | last post by:
Does the C standard include a library function to convert an 8 bit character string to a 16 bit character string?
4
22019
by: uday.sen | last post by:
Hi, I need to convert a string from UTF8 to wide character (wchar_t *). I perform the same in windows using: MultiByteToWideChar(CP_UTF8, 0, pInput, -1, pOutput, nLen); However, in linux this API is not available. However, there exists mbstowcs() API, which converts multibyte string to wide character. But will this API convert UTF8 encoded string to wide character? Or this
4
17764
by: thinktwice | last post by:
i'm using VC++6 IDE i know i could use macros like A2T, T2A, but is there any way more decent way to do this?
9
9612
by: toton | last post by:
Hi, I have my program using wstring everywhere instead of string. Similarly I need to process some file, which contains unicode or ascii character. I need to stream them. Thus I use wifstream etc. However the open member function of is not templated, and use const char* as filename. I have my filename as wstring, where c_str() returns const wchar_t* type. Thus how to convert a wstring to string or const char* and pass to open of wifstream?
1
3594
by: iwongu | last post by:
Hi, I have a question about std::wcout and its underlying C functions. According to C99, a stream have an orientation type that is one of byte-oriented or wide-one, and it is determined by the first using C function on that stream. And the specific orientation functions should not be applied to the stream that have other orientation.
0
8381
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
8893
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...
1
8586
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
8658
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...
1
6209
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
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();...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2026
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1786
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.