(我会将此作为答案,因为将其作为评论太大了,从技术上讲,这个问题的答案应该是:“你不能,没有可供外部使用的 Informix GLS 编译器”)
看看你之前的问题,我猜你想要什么,是一种过滤 ascii 字符的方法。即使你可以,我也不会去写你自己的 gls 定义的路线,它并不像听起来那么简单。
Informix 有一个普通的 ASCII 语言环境:
d:\infx\ids12\gls\cm3>grep ASCII registry
# ASCII characters (except that a code-set name cannot begin with
# The code-set number consists of 1 or more decimal ASCII digits
ASCII 364 # 0x016c
d:\infx\ids12\gls\cm3>
只有某些语言有它(如德语或西班牙语):
d:\infx\ids12\gls\cm3>dir ..\..\016c.* /s
Volume in drive D is Data750
Volume Serial Number is F0B7-2E46
Directory of d:\infx\ids12\gls\cm3
21/01/2017 20:23 6,408 016c.cmo
1 File(s) 6,408 bytes
Directory of d:\infx\ids12\gls\lc11\de_de
21/01/2017 20:25 4,369 016c.lco
1 File(s) 4,369 bytes
Directory of d:\infx\ids12\gls\lc11\es_es
21/01/2017 20:25 4,611 016c.lco
1 File(s) 4,611 bytes
但是没有什么能阻止您将语言环境文件 (.lco) 复制到“en_us”目录并使用它(当然,仅用于测试目的)。
d:\infx\ids12\gls\cm3>cp d:\infx\ids12\gls\lc11\de_de\016c.lco d:\infx\ids12\gls\lc11\en_us
d:\infx\ids12\gls\cm3>
d:\infx\ids12\gls\cm3>dir d:\infx\ids12\gls\lc11\en_us
Volume in drive D is Data750
Volume Serial Number is F0B7-2E46
Directory of d:\infx\ids12\gls\lc11\en_us
09/03/2018 11:07 <DIR> .
09/03/2018 11:07 <DIR> ..
09/03/2018 11:07 4,369 016c.lco
21/01/2017 20:25 2,666 0333.lco
21/01/2017 20:25 7,578 0333dict.lco
21/01/2017 20:25 4,071 0333dres.lco
21/01/2017 20:25 4,096 0333extn.lco
21/01/2017 20:25 4,412 0352.lco
21/01/2017 20:25 7,955 0352dict.lco
21/01/2017 20:25 4,410 04e4.lco
21/01/2017 20:25 7,824 04e4dict.lco
21/01/2017 20:25 7,818 04e4edic.lco
21/01/2017 20:25 4,410 04e4euro.lco
21/01/2017 20:25 63,649 e005.lco
21/01/2017 20:25 85,484 e01c.lco
21/01/2017 20:25 2,668 e02f.lco
21/01/2017 20:25 7,815 e02fdict.lco
21/01/2017 20:25 64,886 e030.lco
16 File(s) 284,111 bytes
2 Dir(s) 234,801,618,944 bytes free
d:\infx\ids12\gls\cm3>
之后,您应该能够使用“en_US.ascii”语言环境创建数据库:
D:\infx\ids12>set DB_LOCALE=en_US.ascii
D:\infx\ids12>set CLIENT_LOCALE=en_US.1252
D:\infx\ids12>dbaccess - -
> create database enusascii with log;
Database created.
> select * from sysmaster:sysdbslocale where dbs_dbsname='enusascii';
dbs_dbsname enusascii
dbs_collate en_US.364
1 row(s) retrieved.
>
如果您尝试插入大于 0x7F 的任何内容,它应该抱怨:
D:\infx\ids12>od -t x1 test_ascii.unl
0000000000 74 D6 73 74 7C 0D 0A
0000000007
D:\infx\ids12>cat test_ascii.unl
t€st|
D:\infx\ids12>
....
Database created.
> create table t1(c1 char(10));
Table created.
> load from test_ascii.unl insert into t1;
23103: Code-set conversion function failed due to illegal sequence or invalid value.
847: Error in load file row 1.
Error in line 1
Near character position 40
>
可以在 819 数据库中加载相同的文件:
D:\infx\ids12>set | grep LOCALE
CLIENT_LOCALE=en_US.1252
DB_LOCALE=en_US.819
D:\infx\ids12>dbaccess enus819 -
Database selected.
> load from test_ascii.unl insert into t1;
1 row(s) loaded.
>
您会得到 23103,因为 GLS 转换函数检测到 0xD6 值 ('Ö') 的无效映射。1252 和 ASCII 之间的转换文件显示大于 0x7F 的任何内容都会引发错误。
<source_version> 2
<modified_date> "05-04-2004"
<source_codeset> "Windows Code Page 1252"
<target_codeset> "ASCII 7-Bit"
# Conversion Table
\x00...\xff \x00... # Default everything onto itself
\x80 \x7f error # euro-sign
\x82 \x7f error # single low-9 quotation mark
\x83 \x7f error # dutch guilder sign (ibm437 159)
.... same.....
....
\xfd \x7f error # latin small letter y with acute
\xfe \x7f error # latin small letter thorn (icelandic)
\xff \x7f error # latin small letter y with diaeresis
请记住,只有在代码集之间发生转换时,您才会收到错误消息。如果您的 CLIENT_LOCALE 与您的 DB_LOCALE 相同,那么当您告诉客户不需要转换时,没有人会“过滤/验证”您的数据。