编码为“ WIN1252”的字节序列为0x9d的字符与编码为“ UTF8”的等效字符 [英] Character with byte sequence 0x9d in encoding 'WIN1252' has no equivalent in encoding 'UTF8'

查看:204
本文介绍了编码为“ WIN1252”的字节序列为0x9d的字符与编码为“ UTF8”的等效字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在读取sql脚本中的csv文件,并将其数据复制到postgre sql表中。代码行如下:

  \从 C:/ Users / Acrotrend / Desktop / mip_sahil / mip / reelportdata / Participating_Individual_Extract_Report_MIPJunior_2013_160414135957.Csv'和CSV分隔符','quote''HEADER; 

我正在获取出现以下错误:编码为'WIN1252'的字节序列为0x9d的字符在编码为'UTF8'时没有等效的字符。我可以解决它吗?

解决方案

问题是 0x9D 不是WIN1252中的有效字节值。
这里有一个表: https://en.wikipedia .org / wiki / Windows-1252



问题可能是您正在导入UTF-8文件,而postgresql默认为Windows-1252(我相信这是许多Windows系统上的默认设置。)



您需要更改字符在Windows命令行上设置 chcp 。或者在postgresql中,您可以:

 将CLIENT_ENCODING设置为 utf8; 

在导入文件之前。


I am reading a csv file in my sql script and copying its data into a postgre sql table. The line of code is below :

\copy participants_2013 from 'C:/Users/Acrotrend/Desktop/mip_sahil/mip/reelportdata/Participating_Individual_Extract_Report_MIPJunior_2013_160414135957.Csv' with CSV delimiter ',' quote '"' HEADER;

I am getting following error : character with byte sequence 0x9d in encoding 'WIN1252' has no equivalent in encoding 'UTF8'.

Can anyone help me with what the cause of this issue and how can I resolve it?

解决方案

The problem is that 0x9D is not a valid byte value in WIN1252. There's a table here: https://en.wikipedia.org/wiki/Windows-1252

The problem may be that you are importing a UTF-8 file and postgresql is defaulting to Windows-1252 (which I believe is the default on many windows systems).

You need to change the character set on your windows command line before running the script with chcp. Or in postgresql you can:

SET CLIENT_ENCODING TO 'utf8';

Before importing the file.

这篇关于编码为“ WIN1252”的字节序列为0x9d的字符与编码为“ UTF8”的等效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆