September 1, 2005 at 1:43 am
Hi All,
I am having a tought time in validating the Chinese/Korean Characters in the Stored Procedure
Assume that i have an Application through which the User will enter Chinese /Korean Characters
The values entered i must validate in the SP before storing them in the table
Following is an Sample Validation
Create proc @validateUnicod
(
@param1 nVarchar(100) --This will have chinese/Korean characters in the Unicode UTF - 8 Format
if @param1 = '/CHEQUE'
begin
end
)
September 1, 2005 at 1:50 am
I'm not sure what you mean.
If you mean that you have to check the input against a string containing characters that only a person who can enter Chinese/Korean could set up then look to user the NCHAR function to build up a string.
For example SELECT NCHAR(65) should produce 'A'.
September 1, 2005 at 2:05 am
Hi thanks for the reply
let me reframe my Question like this
Assume that an user enters Chinese Character like "?" ( Which is Equal to the word "PING" in English) and wants this value to be saved in the SQL Server table. The Frontend Application ensures that before calling the SP to store this value, it converts the chinese character entered to the UNICODE and call the SP to insert the unicode value in the table and when i store this Character , it gets stored as "ƽ" (Unicode Equivalent ) in SQL Server 2000. So before storing this value in the database i want to validate that is passed to the BE. Say in this case i dont want to user enter the value PING in the textbox.
if ( @param1 = 'PING' ) --I cant write a validate stmt in unicode like ( @param1 = 'ƽ')
begin
select 'user cannot enter value ping'
return
end
else
insert the record into the table
September 2, 2005 at 12:40 am
In SQL, if you want to specify unigode string you must use N'' style.
in your case
if ( @param1 = N'PING')
BEGIN
...
Darko
First rule of debugging:
No Code, No Bugs
September 4, 2005 at 10:48 pm
You might take a look at the NCHAR() and UNICODE() functions.
If I understand you rquestion correctly (by no means certain) you're trying to embed validation to disallow certain characters in the unicode range(s) allocated to the CJK unified character set.
You might be trying to do
if @param1 = nchar(21225) --- or whatever other code corresponding to a CJK character
begin
..........
end
else
........
Good luck
February 9, 2006 at 1:42 pm
> Character , it gets stored as "ƽ" (Unicode Equivalent )
That looks like the UTF-8 equivalent, not a Unicode codepoint. Unicode is a character set, not an encoding, so there is no byte sequence in Unicode for a particular character, there is only a character number, or codepoint. It depends what encoding is used to translate the character (codepoint) to a byte sequence, which byte sequence comes out.
This is very relevant here, because I don't think SQL Server 2000 is capable of handling UTF-8 encodings of Unicode. My guess is that it can only handle UCS-2LE (or UTF-16LE) encodings, and those are different byte sequences.
Anyway, if you know the character you want, you can supply the Unicode codepoint and let SQL Server convert it into the appropriate representation (byte sequence) by using the NCHAR function, as mentioned above.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply