Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9350174

Browse files
author
Hiroshi Inoue
committed
Oops I forgot to add new files for multibyte support.
Sorry Eiji.
1 parent9d645fd commit9350174

File tree

2 files changed

+163
-0
lines changed

2 files changed

+163
-0
lines changed

‎src/interfaces/odbc/multibyte.c

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Module :multibyte.c
3+
*
4+
* Description:Mlutibyte related additional function.
5+
*
6+
*Create 2001-03-03 Eiji Tokuya
7+
*
8+
*/
9+
#include<string.h>
10+
#include"multibyte.h"
11+
12+
intmultibyte_client_encoding ;/* Multibyte Client Encoding. */
13+
intmultibyte_status ;/* Multibyte Odds and ends character. */
14+
15+
unsignedchar*multibyte_strchr(unsignedchar*s,unsignedcharc)
16+
{
17+
intmb_st=0 ,i=0;
18+
while (!(mb_st==0&&s[i]==c||s[i]==0))
19+
{
20+
if (s[i]==0)
21+
return (0);
22+
switch (multibyte_client_encoding )
23+
{
24+
caseSJIS:
25+
{
26+
if (mb_st<2&&s[i]>0x80&& !(s[i]>0x9f&&s[i]<0xe0))
27+
mb_st=2;
28+
elseif (mb_st==2)
29+
mb_st=1;
30+
else
31+
mb_st=0;
32+
}
33+
break;
34+
35+
36+
/* Chinese Big5 Support. */
37+
caseBIG5:
38+
{
39+
if (mb_st<2&&s[i]>0xA0 )
40+
mb_st=2;
41+
elseif (mb_st==2 )
42+
mb_st=1;
43+
else
44+
mb_st=0;
45+
}
46+
break;
47+
default:
48+
{
49+
mb_st=0;
50+
}
51+
}
52+
i++;
53+
}
54+
#ifdef_DEBUG
55+
qlog("i = %d\n",i);
56+
#endif
57+
return (s+i);
58+
}
59+
60+
voidmultibyte_init(void)
61+
{
62+
multibyte_status=0;
63+
}
64+
65+
unsignedchar*check_client_encoding(unsignedchar*str)
66+
{
67+
if(strstr(str,"%27SJIS%27")||strstr(str,"'SJIS'")||strstr(str,"'sjis'"))
68+
{
69+
multibyte_client_encoding=SJIS;
70+
return ("SJIS");
71+
}
72+
if(strstr(str,"%27BIG5%27")||strstr(str,"'BIG5'")||strstr(str,"'big5'"))
73+
{
74+
multibyte_client_encoding=BIG5;
75+
return ("BIG5");
76+
}
77+
return ("OHTER");
78+
}
79+
80+
/*
81+
* Multibyte Status Function.
82+
*Inputchar
83+
*Output0: 1 Byte Character.
84+
*1: MultibyteCharacter Last Byte.
85+
*N: MultibyteCharacter Fast or Middle Byte.
86+
*/
87+
intmultibyte_char_check(unsignedchars)
88+
{
89+
switch (multibyte_client_encoding )
90+
{
91+
/* Japanese Shift-JIS(CP932) Support. */
92+
caseSJIS:
93+
{
94+
if (multibyte_status<2&&s>0x80&& !(s>0x9f&&s<0xE0))
95+
multibyte_status=2;
96+
elseif (multibyte_status==2)
97+
multibyte_status=1;
98+
else
99+
multibyte_status=0;
100+
}
101+
break;
102+
103+
104+
/* Chinese Big5(CP950) Support. */
105+
caseBIG5:
106+
{
107+
if (multibyte_status<2&&s>0xA0)
108+
multibyte_status=2;
109+
elseif (multibyte_status==2)
110+
multibyte_status=1;
111+
else
112+
multibyte_status=0;
113+
}
114+
break;
115+
default:
116+
{
117+
multibyte_status=0;
118+
}
119+
}
120+
#ifdef_DEBUG
121+
qlog("multibyte_client_encoding = %d s = 0x%02X multibyte_stat = %d\n",multibyte_client_encoding,s,multibyte_status );
122+
#endif
123+
return(multibyte_status );
124+
}

‎src/interfaces/odbc/multibyte.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
*
3+
* Multibyte library header ( psqlODBC Only )
4+
*
5+
*
6+
*/
7+
8+
/* PostgreSQL client encoding */
9+
#defineSQL_ASCII0/* SQL/ASCII */
10+
#defineEUC_JP1/* EUC for Japanese */
11+
#defineEUC_CN2/* EUC for Chinese */
12+
#defineEUC_KR3/* EUC for Korean */
13+
#defineEUC_TW4/* EUC for Taiwan */
14+
#defineUNICODE5/* Unicode UTF-8 */
15+
#defineMULE_INTERNAL6/* Mule internal code */
16+
#defineLATIN17/* ISO-8859 Latin 1 */
17+
#defineLATIN28/* ISO-8859 Latin 2 */
18+
#defineLATIN39/* ISO-8859 Latin 3 */
19+
#defineLATIN410/* ISO-8859 Latin 4 */
20+
#defineLATIN511/* ISO-8859 Latin 5 */
21+
#defineLATIN612/* ISO-8859 Latin 6 */
22+
#defineLATIN713/* ISO-8859 Latin 7 */
23+
#defineLATIN814/* ISO-8859 Latin 8 */
24+
#defineLATIN915/* ISO-8859 Latin 9 */
25+
#defineKOI816/* KOI8-R */
26+
#defineWIN17/* windows-1251 */
27+
#defineALT18/* Alternativny Variant (MS-DOS CP866) */
28+
#defineSJIS32/* Shift JIS */
29+
#defineBIG533/* Big5 */
30+
#defineWIN125034/* windows-1250 */
31+
32+
33+
externintmultibyte_client_encoding ;/* Multibyte client encoding. */
34+
externintmultibyte_status ;/* Multibyte charcter status. */
35+
36+
voidmultibyte_init(void);
37+
unsignedchar*check_client_encoding(unsignedchar*str);
38+
intmultibyte_char_check(unsignedchars);
39+
unsignedchar*multibyte_strchr(unsignedchar*s,unsignedcharc);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp