• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5430
  • Last Modified:

How to convert content in text file from codepage 65001 (UTF-8) to codepage 1252 during import

I have one textfile containg data in utf-8 format. When I make a new package in the designer i choose codepage 65001 (utf-8), and in the preview window all the characters looks correctly. When I import the file into SQL server and look at the table the characters shows "ugly" (this is for norwegian char). Any idea how to convert the data to codepage 1252 during import to SQL server+
0
Dag-Egil
Asked:
Dag-Egil
  • 3
  • 2
1 Solution
 
reb73Commented:
Just to make sure I understood this correctly - are you trying to transparently convert UTF-8 encoded unicode data to be populated into a non-unicode backend table?

 
0
 
Dag-EgilAuthor Commented:
Yes, that is what I try to do. (I have in the mean time changed how the text file is created, so now I make a non-unicode text file instead, so the "problem" is solved). But I am still interested in if this conversion is possible/recommended.
0
 
reb73Commented:
Converting a unicode value to a non-unicode equivlent is always fraught with risks of values being misinterpreted during the conversion which is why you end up with question marks or boxed characters when this is forced. This wouldn't be recommended and it is advisable to use unicode (nchar, nvarchar) datatypes in the backend table.

The reason is that unicode (UTF-16) notation use two bytes to represent (UTF-8 uses a variable length between 1-4 chars as applicable) and it may not be possible to convert it to a standard 1 byte character (char, varchar).



0
 
Dag-EgilAuthor Commented:
OK, thanks a lot! I guess I stick to my non-unicode file as a permanent solution.
0
 
Dag-EgilAuthor Commented:
Was this comment helpful? Yes No
Dag-Egil:
OK, thanks a lot! I guess I stick to my non-unicode file as a permanent solution.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now