By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,686 Members | 1,840 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,686 IT Pros & Developers. It's quick & easy.

C-cedilla -- Special Character

ddtpmyra
100+
P: 333
I declare to a variable equivaclent to cedil

Expand|Select|Wrap|Line Numbers
  1. DECLARE @TAB CHAR(1)=char(199)
but everytime I export it it's giving me different char. Is there's a way to write U+00C7 which is equivalent to cedill? You help will be much appreciated.

thank you.
Nov 29 '12 #1

✓ answered by Rabbit

You have two options.

1) Use -w instead of -c. -w will encode the text in unicode.
2) Use -c but also specify -C ACP to use code page 1252. Code page 1252, also known as Latin 1, is the most common code page used on windows.

Share this Question
Share on Google+
13 Replies


NeoPa
Expert Mod 15k+
P: 31,769
Only the first 128 characters can be assumed to be standard in ASCII across different character sets. 199 is C-cedilla in one at least, but I look at others and find it's something else entirely. You probably need to look at what is interpreting the character exported and which CharSet it's using.
Nov 29 '12 #2

Rabbit
Expert Mod 10K+
P: 12,430
U+00C7 is unicode, hence the U. If you want to use unicode encoding, then you need to use NCHAR. The rest of your data will have to be converted to NCHAR and NVARCHAR if they are not.

If you want to stay with ASCII, then capital C cedilla is 128 and lower case c cedilla is 135.

If you need to use any of the other cedillas, you will have to switch to unicode.
Nov 29 '12 #3

ddtpmyra
100+
P: 333
@NeoPa:
It interprets it as a '€' char.

@Rabbit:
Can you give me an example of a select that will use U+00C7?
Nov 29 '12 #4

ddtpmyra
100+
P: 333
@NeoPa:
When I select the temp table inside SQL it is in Cedill form but everytime I export it to a .dat file it's different €.

I wonder if I'm using the correct BCP format (below) any other suggestions?
Expand|Select|Wrap|Line Numbers
  1. SELECT @SQL='BCP testfile OUT '+@FILENAME+' -c -t -T -r '+@@SERVERNAME
Nov 29 '12 #5

NeoPa
Expert Mod 15k+
P: 31,769
The contents of the file are not characters as such. The numbers are interpreted as characters by whatever software is used to view them. What character sets it uses depends on how your system is set up.

It may well be that Rabbit's suggestion of using unicode variables (NCHAR & NVARCHAR) to hold your data is the way to go. Have you looked into that yet?
Nov 29 '12 #6

ddtpmyra
100+
P: 333
@NeoPa
Sorry I dont know how to do that. Can you show me how like an example?

thank you.
Nov 29 '12 #7

Rabbit
Expert Mod 10K+
P: 12,430
To create a unicode string, you use the NCHAR function.
Expand|Select|Wrap|Line Numbers
  1. SELECT NCHAR(199)
But here's the thing, just because you write the data in unicode, unless you're also reading it in unicode, it won't look right. What you really need to do is find out the encoding that the reader will be using and then write to match that.
Nov 29 '12 #8

NeoPa
Expert Mod 15k+
P: 31,769
Rabbit's illustration shows how to cast a value into Unicode format - NCHAR(). This would still need to be stored, if it were stored, in a variable that is also defined as NCHAR.

That would indicate that your original line of code would be :
Expand|Select|Wrap|Line Numbers
  1. DECLARE @TAB NCHAR(1)=NCHAR(199)
I'm not sure what the Unicode equivalent of the C-cedilla is though. Probably not 199, but I'm sure you can find that.

PS. Scratch that. It is 199 (or &hC7) for the capital and 131 (or &hE7) for the lower-case. See W3 - Characters Ordered by Unicode.
Nov 29 '12 #9

Rabbit
Expert Mod 10K+
P: 12,430
Yes it is, at least for UCS-2 (which is what SQL Server uses for NCHAR) and also UTF-16, and the equivalent in ASCII for capital C cedilla is 128 and lower case c cedilla is 135. UCS-2 and UTF-16 also use 2-bytes per character whereas ASCII uses only one.
Nov 29 '12 #10

ddtpmyra
100+
P: 333
i can see the cedill in right format when stored on temporary table this is good! But every time I export it to a .dat file it looks like this...



I wonder if the cause of these is because how i called it on my BCP

Expand|Select|Wrap|Line Numbers
  1. SELECT @SQL='BCP Test_File OUT '+@FILENAME+' -c -t -T -S '+@@SERVERNAME 
Nov 29 '12 #11

Rabbit
Expert Mod 10K+
P: 12,430
You have two options.

1) Use -w instead of -c. -w will encode the text in unicode.
2) Use -c but also specify -C ACP to use code page 1252. Code page 1252, also known as Latin 1, is the most common code page used on windows.
Nov 29 '12 #12

ddtpmyra
100+
P: 333
You are awesome NeoPa and Rabbit! It works thank you soooo much for your help!
Nov 29 '12 #13

NeoPa
Expert Mod 15k+
P: 31,769
I'm glad we could help, though TBF I think Rabbit's know-how was probably more helpful than mine for this one. You may want to decide which of the posts helped you nail it in the end and select it as Best Answer. I'd do it for you, but I can't tell where you were most stuck and which one opened the gates for you.
Nov 29 '12 #14

Post your reply

Sign in to post your reply or Sign up for a free account.