UTF8编码字符在WIN1252中无效 [英] Character with encoding UTF8 has no equivalent in WIN1252

查看:1110
本文介绍了UTF8编码字符在WIN1252中无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下异常:

Caused by: org.postgresql.util.PSQLException: ERROR: character 0xefbfbd of encoding "UTF8" has no equivalent in "WIN1252"

有没有办法根除这些字符,通过SQL还是以编程方式?

(应该首选SQL解决方案)

Is there a way to eradicate such characters, either via SQL or programmatically?
(SQL solution should be preferred).

我正在考虑使用WIN1252连接到数据库,但会给同样的问题。

I was thinking of connecting to the DB using WIN1252, but it will give the same problem.

推荐答案

当您收到此消息时,您该怎么办?您是否将文件导入Postgres?正如devstuff所说,这是一个BOM字符。这是一个字符Windows首先写入文本文件,当它以UTF8编码保存时 - 它是不可见的,0-宽度的字符,因此在文本编辑器中打开时不会看到它。

What do you do when you get this message? Do you import a file to Postgres? As devstuff said it is a BOM character. This is a character Windows writes as first to a text file, when it is saved in UTF8 encoding - it is invisible, 0-width character, so you'll not see it when opening it in a text editor.

尝试打开此文件,例如记事本,保存为ANSI编码,并添加(或替换类似的)将client_encoding设置为'WIN1252'行。

Try to open this file in for example Notepad, save-as it in ANSI encoding and add (or replace similar) set client_encoding to 'WIN1252' line in your file.

这篇关于UTF8编码字符在WIN1252中无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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