wcsxfrm to find out length of new collated form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Im using VS Studio. Net 2005 to find out the transformed length of wide char
string based on specific locale (collation).

char* p = setlocale(LC_COLLATE,NULL);//US Locale on my machine.

wchar_t tp[6] = L"Hello";

size_t size = wcsxfrm(NULL, tp, 0);

cout<<"Size "<<size<<endl;

But it seems that I can't pass NULL as destination string since it gives me
runtime error in wcsfrm.c file. But same code works on 2003 studio.

Can anyone suggest me what is wrong with my code.
 
Guru said:
Im using VS Studio. Net 2005 to find out the transformed length of wide char
string based on specific locale (collation).

char* p = setlocale(LC_COLLATE,NULL);//US Locale on my machine.

wchar_t tp[6] = L"Hello";

size_t size = wcsxfrm(NULL, tp, 0);

cout<<"Size "<<size<<endl;

But it seems that I can't pass NULL as destination string since it gives me
runtime error in wcsfrm.c file. But same code works on 2003 studio.

Nothing looks wrong from your code. wcsxfrm is supposed to allow NULL
for the first pointer if the third parameter is 0.
Can anyone suggest me what is wrong with my code.

Hmm, actually I just tried it and it worked fine. Perhaps it wasn't this
part that caused the error?
 
Strange,

Have you tried this with 2005 .net studio, coz I found its not working with
latest vc compiler but its working fine with vc 7 i.e. Studio .Net 2003



Ray said:
Guru said:
Im using VS Studio. Net 2005 to find out the transformed length of wide char
string based on specific locale (collation).

char* p = setlocale(LC_COLLATE,NULL);//US Locale on my machine.

wchar_t tp[6] = L"Hello";

size_t size = wcsxfrm(NULL, tp, 0);

cout<<"Size "<<size<<endl;

But it seems that I can't pass NULL as destination string since it gives me
runtime error in wcsfrm.c file. But same code works on 2003 studio.

Nothing looks wrong from your code. wcsxfrm is supposed to allow NULL
for the first pointer if the third parameter is 0.
Can anyone suggest me what is wrong with my code.

Hmm, actually I just tried it and it worked fine. Perhaps it wasn't this
part that caused the error?
 
Oops sorry i gave wrong code..typing mistake ...please try this with US
locale and not with standard "C" locale.

//Use UNICODE Character set in compiler properties
#include<iostream>
#include<stdio.h>
#include<wchar.h>

using namespace::std;

int main(int argc,char* argv[])
{
wchar_t* p = _wsetlocale(LC_COLLATE,L"");
wchar_t test[6] = L"Hello";
size = wcsxfrm(NULL, tp, 0);
}
 
Hi Guru,

Guru said:
Im using VS Studio. Net 2005 to find out the transformed length of wide
char
string based on specific locale (collation).

char* p = setlocale(LC_COLLATE,NULL);//US Locale on my machine.

wchar_t tp[6] = L"Hello";

size_t size = wcsxfrm(NULL, tp, 0);

Looks like a bug in the c-runtime of 8.0. This is the offending code:
*_string1 = '\0';

it is in wcsxfrm.c in line 125. _string1 is the name of the first parameter
which in the above call is given a NULL. So it obviously dereferencing a
NULL pointer.

Can some from Microsoft confirm this?
 
Hi SvenC

thanks for reply..

Please have a look at this feedback..I submitted below feedback on micorosft
site and later on realised they are pointing to same source code in wcsxfrmc.c

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99607

Thanks
Guru

SvenC said:
Hi Guru,

Guru said:
Im using VS Studio. Net 2005 to find out the transformed length of wide
char
string based on specific locale (collation).

char* p = setlocale(LC_COLLATE,NULL);//US Locale on my machine.

wchar_t tp[6] = L"Hello";

size_t size = wcsxfrm(NULL, tp, 0);

Looks like a bug in the c-runtime of 8.0. This is the offending code:
*_string1 = '\0';

it is in wcsxfrm.c in line 125. _string1 is the name of the first parameter
which in the above call is given a NULL. So it obviously dereferencing a
NULL pointer.

Can some from Microsoft confirm this?

--
SvenC
cout<<"Size "<<size<<endl;

But it seems that I can't pass NULL as destination string since it gives
me
runtime error in wcsfrm.c file. But same code works on 2003 studio.

Can anyone suggest me what is wrong with my code.
 
Back
Top