gpt4 book ai didi

Smalltalk FFI 调用 OpenDBX 中的 unicode 字符

转载 作者:行者123 更新时间:2023-12-01 18:43:51 25 4
gpt4 key购买 nike

我需要将一些包含非 ASCII 字符的字符串插入数据库(Postgress)。这是最小的例子。我在 <cdecl: long 'odbx_query' (ulong char* ulong) module: 'opendbx'> 上收到“无法强制论证” 。据我了解,这是一个 FFI 错误,调用甚至没有到达数据库后端,但我不确定。

| conn settings sql |
settings := DBXConnectionSettings
host: 'host.com'
port: '5432'
database: 'grss'
userName: 'username'
userPassword: 'password'.
conn := DBXConnection platform: DBXPostgresPlatform new settings: settings.
conn connectAndOpen.
sql := 'select ''', (WideString fromPacked: 269), ''' from dual'.
conn execute: sql.
conn close.
conn disconnect.

最佳答案

我想我也遇到了同样的问题。人们应该使用与服务器相同的编码对数据进行编码。目前您应该能够通过以下方式指定编码:

settings :=     DBXConnectionSettings
host: 'host.com'
port: '5432'
database: 'grss'
userName: 'username'
userPassword: 'password';
encodingStrategy: (DBXStaticEncoding newForEncoding: #utf8).

如果编码未知,可以使用 DBXAutomaticEncoding 而不是 DBXStaticEncoding。这应该适用于 postgresql 数据库。

关于Smalltalk FFI 调用 OpenDBX 中的 unicode 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5212790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com