11 #define ASSIGN_SETUP(dst, src, _type) _
12 dim as integer dst_len, src_len :_
14 if( src = NULL )
then :_
17 src_len =
len( *src ) :_
20 if( src_len = 0 )
then :_
21 if( *dst <> NULL )
then :_
28 if( *dst = NULL )
then :_
31 dst_len =
len( **dst ) :_
34 if( dst_len <> src_len )
then :_
35 *dst =
xallocate( (src_len+1) *
len( _type ) ) :_
39 #define CONCATASSIGN_SETUP(dst, src, _type) _
40 dim as integer dst_len, src_len :_
42 if( src = NULL )
then :_
46 src_len =
len( *src ) :_
47 if( src_len = 0 )
then :_
51 if( *dst = NULL )
then :_
53 *dst =
xallocate( (src_len+1) *
len( _type ) ) :_
55 dst_len =
len( **dst ) :_
56 *dst = xreallocate( *dst, (dst_len+src_len+1) *
len( _type ) ) :_
62 byval dst
as zstring ptr ptr, _
63 byval src
as zstring ptr _
66 ASSIGN_SETUP( dst, src,
zstring )
68 if( *dst <> NULL )
then
77 byval dst
as zstring ptr ptr, _
78 byval src
as wstring ptr _
81 ASSIGN_SETUP( dst, src,
zstring )
83 if( *dst <> NULL )
then
92 byval dst
as zstring ptr ptr, _
93 byval src
as zstring ptr _
96 CONCATASSIGN_SETUP( dst, src,
zstring )
98 if( *dst <> NULL )
then
99 *(*dst + dst_len) = *src
107 byval dst
as zstring ptr ptr, _
108 byval src
as wstring ptr _
111 CONCATASSIGN_SETUP( dst, src,
zstring )
113 if( *dst <> NULL )
then
114 *(*dst + dst_len) = *src
123 byval dst
as wstring ptr ptr, _
124 byval src
as wstring ptr _
127 ASSIGN_SETUP( dst, src,
wstring )
129 if( *dst <> NULL )
then
138 byval dst
as wstring ptr ptr, _
139 byval src
as zstring ptr _
142 ASSIGN_SETUP( dst, src,
wstring )
144 if( *dst <> NULL )
then
153 byval dst
as wstring ptr ptr, _
154 byval src
as wstring ptr _
157 CONCATASSIGN_SETUP( dst, src,
wstring )
159 if( *dst <> NULL )
then
160 *(*dst + dst_len) = *src
168 byval dst
as wstring ptr ptr, _
169 byval src
as zstring ptr _
172 CONCATASSIGN_SETUP( dst, src,
wstring )
174 if( *dst <> NULL )
then
175 *(*dst + dst_len) = *src
183 byval s
as zstring ptr _
186 dim as zstring ptr dst
198 byval s
as wstring ptr _
201 dim as wstring ptr dst
203 dst =
xallocate(
len( *s ) *
len(
wstring ) +
len(
wstring ) )
213 byval orgtext
as zstring ptr, _
214 byval oldtext
as zstring ptr, _
215 byval newtext
as zstring ptr _
218 dim as integer oldlen, newlen, p
219 static as string text, remtext
221 oldlen =
len( *oldtext )
222 newlen =
len( *newtext )
227 p =
instr( p+1, text, *oldtext )
232 remtext =
mid( text, p + oldlen )
233 text =
left( text, p-1 )
246 byval orgtext
as wstring ptr, _
247 byval oldtext
as wstring ptr, _
248 byval newtext
as wstring ptr _
249 )
as wstring ptr static
251 dim as integer oldlen, newlen, p
252 static as DWSTRING text, remtext
254 oldlen =
len( *oldtext )
255 newlen =
len( *newtext )
261 p =
instr( p+1, *text.
data, *oldtext )
266 DWstrAssign( remtext,
mid( *text.
data, p + oldlen ) )
280 byval orgtext
as zstring ptr, _
281 byval oldchar
as integer, _
282 byval newchar
as integer _
285 for i
as integer = 0
to len( *orgtext ) - 1
286 if( orgtext[i] = oldchar )
then
298 byval text
as zstring ptr, _
299 byref textlen
as integer, _
300 byref isunicode
as integer _
301 )
as zstring ptr static
303 static as DZSTRING res
304 dim as integer char, lgt, i, value, isnumber
305 dim as zstring ptr src, dst, src_end
323 do while( src < src_end )
328 if( char = CHAR_RSLASH )
then
330 if( src >= src_end )
then exit do
333 *dst = FB_INTSCAPECHAR
343 case CHAR_0
to CHAR_9
346 value = (char - CHAR_0)
349 if( src >= src_end )
then exit for
352 if( (char < CHAR_0)
or (char > CHAR_9) )
then
355 value = (value * 10) + (char - CHAR_0)
359 case CHAR_AMP, CHAR_XUPP, CHAR_XLOW
360 if( src >= src_end )
then exit do
364 if( char = CHAR_AMP )
then
372 select case as const char
374 case CHAR_HUPP, CHAR_HLOW
379 if( src >= src_end )
then exit for
383 case CHAR_ALOW
to CHAR_FLOW, _
384 CHAR_AUPP
to CHAR_FUPP, _
388 char -= (CHAR_AUPP - CHAR_9 - 1)
391 char -= (CHAR_ALOW - CHAR_AUPP)
394 value = (value * 16) + char
403 case CHAR_OUPP, CHAR_OLOW
408 if( src >= src_end )
then exit for
411 if( (char < CHAR_0)
or (char > CHAR_7) )
then
414 value = (value * 8) + (char - CHAR_0)
419 case CHAR_BUPP, CHAR_BLOW
424 if( src >= src_end )
then exit for
427 if( (char < CHAR_0)
or (char > CHAR_1) )
then
430 value = (value * 2) + (char - CHAR_0)
476 dst[0] = FB_INTSCAPECHAR
493 if(
cuint( value ) > 255 )
then
502 elseif( value < 64 )
then
536 byval text
as wstring ptr, _
537 byref textlen
as integer _
538 )
as wstring ptr static
540 static as DWSTRING res
541 dim as integer char, lgt, i, isnumber
542 dim as uinteger value
543 dim as wstring ptr src, dst, src_end
560 do while( src < src_end )
565 if( char = CHAR_RSLASH )
then
567 if( src >= src_end )
then exit do
570 *dst = FB_INTSCAPECHAR
580 case CHAR_0
to CHAR_9
583 value = (char - CHAR_0)
586 if( src >= src_end )
then exit for
589 if( (char < CHAR_0)
or (char > CHAR_9) )
then
592 value = (value * 10) + (char - CHAR_0)
596 case CHAR_AMP, CHAR_XUPP, CHAR_XLOW
597 if( src >= src_end )
then exit do
601 if( char = CHAR_AMP )
then
609 select case as const char
611 case CHAR_HUPP, CHAR_HLOW
616 if( src >= src_end )
then exit for
620 case CHAR_ALOW
to CHAR_FLOW, _
621 CHAR_AUPP
to CHAR_FUPP, _
625 char -= (CHAR_AUPP - CHAR_9 - 1)
628 char -= (CHAR_ALOW - CHAR_AUPP)
631 value = (value * 16) + char
640 case CHAR_OUPP, CHAR_OLOW
645 if( src >= src_end )
then exit for
648 if( (char < CHAR_0)
or (char > CHAR_7) )
then
651 value = (value * 8) + (char - CHAR_0)
656 case CHAR_BUPP, CHAR_BLOW
661 if( src >= src_end )
then exit for
664 if( (char < CHAR_0)
or (char > CHAR_1) )
then
667 value = (value * 2) + (char - CHAR_0)
704 dst[0] = FB_INTSCAPECHAR
721 if(
cuint( value ) > 65535 )
then
729 do while( value > 7 )
762 byval text
as const zstring ptr _
763 )
as const zstring ptr static
765 static as DZSTRING res
766 dim as integer c, octlen, lgt
768 dim as zstring ptr dst
785 do while( src < src_end )
790 case CHAR_RSLASH, CHAR_QUOTE
798 if( src >= src_end )
then exit do
803 if( c >= 1
and c <= 3 )
then
805 if( src >= src_end )
then exit do
810 case 0 to 31, 128
to 255
817 elseif( c < 64 )
then
818 *dst = CHAR_0 + (c
shr 3)
820 c = CHAR_0 + (c
and 7)
823 dst[0] = CHAR_0 + (c
shr 6)
824 dst[1] = CHAR_0 + ((c
and &b00111000)
shr 3)
826 c = CHAR_0 + (c
and 7)
835 if( octlen > 0 )
then
837 if( octlen = 0 )
then
855 byval char
as integer _
858 select case as const char
862 case asc(
"l" ),
asc(
"n" )
869 function = CHAR_BKSPC
875 function = CHAR_FORMFEED
889 byval text
as zstring ptr _
898 if( *text = CHAR_RSLASH )
then
902 select case as const char
914 CHAR_ULOW, CHAR_UUPP, _
932 byval text
as wstring ptr _
941 if( *text = CHAR_RSLASH )
then
945 select case as const char
957 CHAR_ULOW, CHAR_UUPP, _
975 byval src
as wstring ptr _
978 dim as uinteger char, c
989 c -= (CHAR_AUPP - CHAR_9 - 1)
992 c -= (CHAR_ALOW - CHAR_AUPP)
995 char = (char * 16)
or c
1006 byval text
as wstring ptr _
1007 )
as zstring ptr static
1009 static as DZSTRING res
1010 dim as uinteger char, c
1011 dim as integer lgt, i, wcharlen
1012 dim as wstring ptr src, src_end
1013 dim as zstring ptr dst
1017 wcharlen = typeGetSize( FB_DATATYPE_WCHAR )
1032 do while( src < src_end )
1037 if( char = FB_INTSCAPECHAR )
then
1038 if( src >= src_end )
then exit do
1045 if( (char >= 1)
and (char <= 6) )
then
1049 if( src + i > src_end )
then exit do
1052 char = (char * 8) + (*src - CHAR_0)
1059 if( char =
asc(
"u" ) )
then
1060 if( src + 4 > src_end )
then exit do
1074 for i = 1
to wcharlen
1084 elseif( c < 64 )
then
1085 dst[0] = CHAR_0 + (c
shr 3)
1086 dst[1] = CHAR_0 + (c
and 7)
1090 dst[0] = CHAR_0 + (c
shr 6)
1091 dst[1] = CHAR_0 + ((c
and &b00111000)
shr 3)
1092 dst[2] = CHAR_0 + (c
and 7)
1111 byval text
as zstring ptr _
1112 )
as zstring ptr static
1114 static as DZSTRING res
1115 dim as integer char, lgt, i
1116 dim as zstring ptr src, dst, src_end
1129 do while( src < src_end )
1133 if( char = FB_INTSCAPECHAR )
then
1135 if( src >= src_end )
then exit do
1140 if( (char >= 1)
and (char <= 3) )
then
1144 char = (char * 8) + (*src - CHAR_0)
1173 byval text
as wstring ptr _
1174 )
as wstring ptr static
1176 static as DWSTRING res
1177 dim as integer char, lgt, i
1178 dim as wstring ptr src, dst, src_end
1191 do while( src < src_end )
1195 if( char = FB_INTSCAPECHAR )
then
1197 if( src >= src_end )
then exit do
1204 if( (char >= 1)
and (char <= 6) )
then
1208 char = (char * 8) + (*src - CHAR_0)
1215 if( char =
asc(
"u" ) )
then
1216 if( src + 4 > src_end )
then exit do
1242 byval ch
as integer, _
1243 byval quotechar
as integer _
1249 function = (ch < 32)
or (ch >= 127)
or _
1250 (ch =
asc( $
"\" ))
or (ch = quotechar)
1254 function = ((ch >=
asc(
"0" ))
and (ch <=
asc(
"9" )))
or _
1255 ((ch >=
asc(
"a" ))
and (ch <=
asc(
"f" )))
or _
1256 ((ch >=
asc(
"A" ))
and (ch <=
asc(
"F" )))