Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

_wcsupr () with german characters
Hi,
I have  a string which contains some german characters e.g 'Menü'. I
am converting it to upper case using wcsupr (). But ü is not converted to Ü.
There are other characters too. I can use the _wsetlocale () function before
using _wcsupr (). I cannot use the current machines locale setting. The
strings have to be converted to upper case based on the locale of the target
machine which is a SQL Server. What's the most efficient way of converting
the string to upper case considering the language specific characters. I
tried using the _wsetlocale (LC_CTYPE , L".OCP"); which uses the OEM code
page. This seems to be working. What's the difference in OEM code page and
language specific code page?

Thanks in advance

Ajey




Report this thread to moderator Post Follow-up to this message
Old Post
Ajey
03-30-05 02:40 PM


RE: _wcsupr () with german characters
Hi

The easiest way may be to use the UPPER function when retrieving/saving the
data

SELECT UPPER( 'Menü')

----
MENÜ

John

"Ajey" wrote:

> Hi,
>       I have  a string which contains some german characters e.g 'Menü'. 
I
> am converting it to upper case using wcsupr (). But ü is not converted to
 Ü.
> There are other characters too. I can use the _wsetlocale () function befo
re
> using _wcsupr (). I cannot use the current machines locale setting. The
> strings have to be converted to upper case based on the locale of the targ
et
> machine which is a SQL Server. What's the most efficient way of converting
> the string to upper case considering the language specific characters. I
> tried using the _wsetlocale (LC_CTYPE , L".OCP"); which uses the OEM code
> page. This seems to be working. What's the difference in OEM code page and
> language specific code page?
>
> Thanks in advance
>
>  Ajey
>
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
John Bell
03-30-05 02:40 PM


Re: _wcsupr () with german characters
There are many such string. I cannot use sql query for each to just make it
a upper case. Is there a way i can find out exact local the SQL Server is
using or is there any documentation of which API UPPER function insql uses.

"John Bell" < JohnBell@discussions
.microsoft.com> wrote in message
news:E55039D7-F207-4131-AF23- 4E603E29A38D@microso
ft.com...
> Hi
>
> The easiest way may be to use the UPPER function when retrieving/saving
the
> data
>
> SELECT UPPER( 'Menü')
>
> ----
> MENÜ
>
> John
>
> "Ajey" wrote:
> 
I 
to Ü. 
 before[color=darkred
] 
 target[color=darkred
] 
 converting[color=dar
kred] 
code 
and 



Report this thread to moderator Post Follow-up to this message
Old Post
Ajey
03-30-05 02:40 PM


Re: _wcsupr () with german characters
If i get the code page from the SQL Server as 1252 where as the language on
server is german but the machine where i am running the API has English,
will  _wsetlocale(LC_CTYPE
, L".1252") work fine. Are code page number specifc
to languages or they cover range of languages. (I want to make sure that
code page 1252 is not different for german and different for english)

"Ajey" <ajey5@hotmail.com> wrote in message
news:OJYC$WQNFHA.688@TK2MSFTNGP10.phx.gbl...
> There are many such string. I cannot use sql query for each to just make
it
> a upper case. Is there a way i can find out exact local the SQL Server is
> using or is there any documentation of which API UPPER function insql
uses.
>
> "John Bell" < JohnBell@discussions
.microsoft.com> wrote in message
> news:E55039D7-F207-4131-AF23- 4E603E29A38D@microso
ft.com... 
> the 
'Menü'.
> I 
> to Ü. 
> before 
The 
> target 
> converting 
I 
> code 
> and 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Ajey
03-30-05 02:40 PM


Re: _wcsupr () with german characters
"Ajey" <ajey5@hotmail.com> schrieb im Newsbeitrag =
news:OkTRS$ONFHA.1528@TK2MSFTNGP09.phx.gbl...
> Hi,
>       I have  a string which contains some german characters e.g =
'Men=FC'. I
> am converting it to upper case using wcsupr (). But =FC is not =
converted to =DC.
> There are other characters too. I can use the _wsetlocale () function =
 before
> using _wcsupr (). I cannot use the current machines locale setting. =
The
> strings have to be converted to upper case based on the locale of the =
 target
> machine which is a SQL Server. What's the most efficient way of =
 converting
> the string to upper case considering the language specific characters. =
I
> tried using the _wsetlocale (LC_CTYPE , L".OCP"); which uses the OEM =
code
> page. This seems to be working. What's the difference in OEM code page =
and
> language specific code page?

wcsupr should be independent of the current locale. However, there seems =
to be a bug in the implementation of wcsupr. It first checks the current =
locale and if the "C" locale is used, it simply translates 'a'-'z' to =
upper case but ignores all other letters. If you select any locale =
different form the "C" locale, the string will be translated correctly. =
So, your call to setlocale does fix that bug, but using an OEM codepage =
might introduce other problems. Using the current ANSI codepage (".ACP") =
probably is a better choice.

If you are very cautions, you should implement your own to-upper =
function that selects a reasonable codepage and later restores the =
original one. Something like

void ToUpper(wchar_t* s)
{
char const* loc =3D setlocale(LC_CTYPE, ".ACP");
wcsupr(s);
setlocale(LC_CTYPE, loc);
}

As long as you feed unicode strings (wchar_t) to your SQL server, you =
shouldn't have to worry about locales. You only have to select some =
locale to fix that stupid bug of wcsupr.

HTH
Heinz

Report this thread to moderator Post Follow-up to this message
Old Post
Heinz Ozwirk
03-30-05 02:40 PM


Re: _wcsupr () with german characters
Is the setting applicable to current thread only or to entire program (all
threads)?

"Heinz Ozwirk" <hozwirk.SPAM@arcor.de> wrote in message
 news:424a7cd4$0$1147
 7$9b4e6d93@newsread2
.arcor-online.net...

"Ajey" <ajey5@hotmail.com> schrieb im Newsbeitrag
news:OkTRS$ONFHA.1528@TK2MSFTNGP09.phx.gbl...
> Hi,
>       I have  a string which contains some german characters e.g 'Menü'. I
> am converting it to upper case using wcsupr (). But ü is not converted to
Ü.
> There are other characters too. I can use the _wsetlocale () function
 before
> using _wcsupr (). I cannot use the current machines locale setting. The
> strings have to be converted to upper case based on the locale of the
 target
> machine which is a SQL Server. What's the most efficient way of converting
> the string to upper case considering the language specific characters. I
> tried using the _wsetlocale (LC_CTYPE , L".OCP"); which uses the OEM code
> page. This seems to be working. What's the difference in OEM code page and
> language specific code page?

wcsupr should be independent of the current locale. However, there seems to
be a bug in the implementation of wcsupr. It first checks the current locale
and if the "C" locale is used, it simply translates 'a'-'z' to upper case
but ignores all other letters. If you select any locale different form the
"C" locale, the string will be translated correctly. So, your call to
setlocale does fix that bug, but using an OEM codepage might introduce other
problems. Using the current ANSI codepage (".ACP") probably is a better
choice.

If you are very cautions, you should implement your own to-upper function
that selects a reasonable codepage and later restores the original one.
Something like

void ToUpper(wchar_t* s)
{
char const* loc = setlocale(LC_CTYPE, ".ACP");
wcsupr(s);
setlocale(LC_CTYPE, loc);
}

As long as you feed unicode strings (wchar_t) to your SQL server, you
shouldn't have to worry about locales. You only have to select some locale
to fix that stupid bug of wcsupr.

HTH
Heinz



Report this thread to moderator Post Follow-up to this message
Old Post
Ajey
03-30-05 02:40 PM


Re: _wcsupr () with german characters
Hi

If you always require uppercase then you may think about changing the
data and adding contraints to make sure it is always in uppercase.

Changing you queries may actually be less work than changing the code
especially if you are using stored procedures.

John
Ajey  wrote:
> There are many such string. I cannot use sql query for each to just
make it
> a upper case. Is there a way i can find out exact local the SQL
Server is
> using or is there any documentation of which API UPPER function insql
uses.
>
> "John Bell" < JohnBell@discussions
.microsoft.com> wrote in message
> news:E55039D7-F207-4131-AF23- 4E603E29A38D@microso
ft.com... 
retrieving/ saving[color=darkred
]
> the 
'Men=FC'.
> I 
 converted[color=dark
red]
> to =DC. 
 function[color=darkr
ed]
> before 
setting. The 
the
> target 
> converting 
characters. I 
OEM
> code 
page
> and 


Report this thread to moderator Post Follow-up to this message
Old Post
John Bell
03-31-05 12:01 PM


Re: _wcsupr () with german characters
"Ajey" <ajey5@hotmail.com> schrieb im Newsbeitrag =
news:e6a6QnRNFHA.3328@TK2MSFTNGP14.phx.gbl...
> Is the setting applicable to current thread only or to entire program =
(all
> threads)?

The code looks like it should be thread specific. Give it a try...

HTH
Heinz

Report this thread to moderator Post Follow-up to this message
Old Post
Heinz Ozwirk
03-31-05 12:01 PM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 08:43 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006