postgresql - postgres COPY 功能是否支持 utf 16 编码文件?
问题描述
我正在尝试使用 postgreSQLCOPY
函数将 UTF 16 编码的 csv 插入表中。但是,在运行以下查询时:
COPY temp
FROM 'C:\folder\some_file.csv'
WITH (
DELIMITER E'\t',
FORMAT csv,
HEADER);
我收到以下错误:
ERROR: invalid byte sequence for encoding "UTF8": 0xff
CONTEXT: COPY temp, line 1
SQL state: 22021
当我运行相同的查询,但添加编码设置Encoding 'UTF-16'
或Encoding 'UTF 16'
with 块时,我收到以下错误:
ERROR: argument to option "encoding" must be a valid encoding name
LINE 13: ENCODING 'UTF 16' );
^
SQL state: 22023
Character: 377
我查看了 postgres 文档以尝试找到正确的编码,但没有找到任何东西。这是因为复制功能确实支持 UTF 16 编码文件吗?我原以为这几乎肯定是可能的!
我在 windows 10 pro 上运行 postgres 12
任何帮助将不胜感激!
解决方案
不,你不能那样做。
UTF-16 is not in the list of supported encodings.
PostgreSQL will never support an encoding that is not an extension of ASCII.
You will have to convert the file to UTF-8.
推荐阅读
- templates - 键入 trait 以检查 Eigen 类型是表达式(无存储)还是矩阵或数组(有存储)?
- bash - Dockerfile 不会替换文本,但命令行会,可能的错误?
- google-calendar-api - Google Calendar API - 更深入地了解日历使用限制超出错误
- python-3.x - 构建失败:没有名为 virtualenv 的模块
- c++ - 错误 C2440:“=”:无法从“const char *”转换为“LPCWSTR”
- python - 如何通过 Windows 身份验证将 JSON 导入 Pandas 数据框
- ios - 您的应用使用“prefs:root=”非公共 URL 方案。更新旧代码的最佳计划?
- c++ - 安装 OPEN-MPI 时的问题
- php - 使用 GoDaddy 的 SMTP 服务器电子邮件无法连接
- json - 由于类型转换错误,无法对 JSON 数组进行分组