3

我在使用 LiveCode 时遇到了这个问题,但我不知道这是问题所在还是与 ODBC 驱动程序有关。

LiveCode 内置的应用程序定期通过 ODBC 连接到 SQL Server 数据库,以检索各种数据。

负责数据库的应用程序正在升级,作为其中的一部分,所有文本字段都将转换为 Unicode 文本字段。本质上,这意味着以前定义为 varchar 的字段现在定义为 nvarchar,而以前定义为 text 的字段现在定义为 ntext。(顺便说一下,这是 SQL Server 2008。)

使用我们过去一直使用的查询,我们现在得到一个字符(字段中的第一个字符)而不是整个文本。我现在可以通过在选择查询中指定到 varchar 的转换来解决这个问题,例如,应用程序曾经发出请求,如 SELECT id,name FROM tab1 它现在发出请求,如 SELECT id,convert(varchar(255) , name) AS name FROM tab1

这行得通——我找回了以前得到的东西——但是(a)它很笨拙,(b)现在这很好,当客户只是将他们所有现有的数据迁移到数据库中时,但迟早他们可能会真正采取利用这次升级可以在字段中输入一些 Unicode 字符,然后我大概不会把它们弄出来。

不幸的是,我无权访问数据库或应用程序以插入测试数据——但我假设这个问题会出现——而且很可能它不会很明显,即我的只是一个微妙的问题应用程序没有处理输入的数据(但认为是)。

那么:有没有办法让 LiveCode 应用程序使用当前的 ODBC 驱动程序从 nvarchar 或 ntext 字段中正确检索完整数据?

4

3 回答 3

1

您是否可以使用 revDataFromQuery 而不是更强大的 revQueryDatabase?我不使用 revDataFromQuery 但我猜它使用的是不支持 UTF16 的 c 字符串函数。

于 2013-03-19T23:06:36.297 回答
0

Hmmm. Depends on where the conversion is taking place. I haven't had to deal with this one, so take this with a grain of salt...

If the whole unicode result is making its way through the odbc driver and LiveCode's db layer then you should be able to unidecode the result. It looks like you're getting back double-byte chars and the second byte is zero, which will null-terminate the string if it's being treated as single-byte chars. This, as you noted, is what's happening when you do the conversion to varchar in the SQL request.

If the conversion is taking place in either the odbc layer or LC's db layer, then you're out of luck until that becomes open source and can be rewritten to handle unicode.

So I would say don't do the conversion to varchar, try to unidecode the result before examining it, and you've got a good chance of seeing what you expect.

于 2013-03-19T16:43:21.973 回答
0

因此,为了任何遇到此问题的人的利益:事实证明,如果我只阅读文档的正确部分,我应该知道的问题是我在简单模式下使用 revDatabaseColumnNumbered -

put revDatabaseColumnNumbered(iConnID, iColNum) into tData

...但该模式只能返回文本,这实际上不是我们这里所拥有的,而是二进制数据。所以解决方法是使用第二种模式,

get revDatabaseColumnNumbered(iConnID, iColNum, "tData")

...此时我们获得了完整的 Unicode 数据,然后可以决定如何处理它。根本不是revQueryDatabase代码路径的错误,只是我在使用revDatabaseColumnNumbered.

感谢所有试图帮助我的人!

于 2014-01-02T18:49:43.657 回答