简体   繁体   English

Delphi XE Unicode处理nchar(1)字段

[英]Delphi XE Unicode dealing with nchar(1) fields

I'm using a dbGo TADODataset in Delphi XE to read data from a SQL Server 2008 table. 我在Delphi XE中使用dbGo TADODataset从SQL Server 2008表读取数据。 All the string fields are nvarchar or nchar. 所有的字符串字段都是nvarchar或nchar。

The nvarchar fields map to TWideStringField with no problems. nvarchar字段TWideStringField地映射到TWideStringField

The problem is with an nchar(1) field, this maps to a TStringField fine but not to a TWideStringField - when I configure the field to be TWideStringField I get the error: 问题在于nchar(1)字段,它映射到TStringField很好,但不映射到TWideStringField当我将字段配置为TWideStringField ,出现错误:

Type mismatch for field 'foobar' , expecting: WideString actual: FixedChar 字段'foobar'类型不匹配, FixedCharWideString实际值: FixedChar

The problem in using a TStringField is that it is UTF8 and we want to make our application fully unicode compliant. 使用TStringField的问题在于它是UTF8,我们希望使我们的应用程序完全符合Unicode。

Any suggestions on this? 有什么建议吗?

Hmmm. That field is used for what, exactly? 该字段用于什么呢?

In most db designs I've seen, an (n)Char(1) field are normally used for one-letter flags - which can be easily represented in an ASCII char. 在我见过的大多数数据库设计中,(n)Char(1)字段通常用于一个字母的标志-可以很容易地用ASCII字符表示。

I would recomend change the type of the column to CHAR(1), if that's the case. 如果是这种情况,我建议将列的类型更改为CHAR(1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM