1

可能重复:
使用 BULK INSERT 未正确导入重音字符

在我的系统中运行的 .net 程序为我提供了一个 csv 文件。我想知道那个文件的编码。

csv 文件包含é, ä, å,æ字符,但显示为 �(UTF8-with BOM)。有没有可能我可以将这些字符押回其原始字符或类似英语的字符。

csv 文件是由同一用户在同一台​​机器上运行的 .net 程序创建的,但在创建文件后我看不到原始字符。

相关问题。

sample data (UTF8-Without BOM) from csv file. 

Pok�mon Black Version
TGC � Nintendo
on H�tel de R�ve  
La Reine Masqu�e et la Tour des Miroirs 
4

2 回答 2

6
于 2012-12-19T14:47:15.380 回答
1

I agree with Esailija. Appears this data was single byte before it got to SQL.

In case the SQL was the problem will post as answer.

In SQL:

char and nchar are both single byte (ansii).

nchar and nvarchar are double byte (unicode).

If you load unicode into char it get packed into single byte.
I have loaded unicode into char and any uncode > 255 was translated to �.

Using Unicode Data

How to test

SELECT CAST('a' AS char(1))

SELECT CAST('é' AS char(1))
notice this works as extended ASCII (<255)

SELECT CAST(N'Ƶ' AS char(1))

SELECT CAST(N'Ƶ' AS nchar(1))

SELECT CAST(N'Ƹ' AS char(1))

SELECT CAST(N'Ƹ' AS nchar(1))

notice Ƶ and Ƹ both cast to same ? (for don't know)

于 2012-12-19T15:32:07.357 回答