12 #define UTF16_MAX_BMP &h0000FFFF
13 #define UTF16_SUR_HIGH_START &hD800
14 #define UTF16_SUR_HIGH_END &hDBFF
15 #define UTF16_SUR_LOW_START &hDC00
16 #define UTF16_SUR_LOW_END &hDFFF
17 #define UTF16_HALFSHIFT 10
18 #define UTF16_HALFBASE &h0010000UL
19 #define UTF16_HALFMASK &h3FFUL
21 #define U16_SWAP(c) (((c)
shr 8)
or ((c)
shl 8)
and &hFF00)
23 #define U32_SWAP(c) (((c)
shr 24)
or (((c)
shl 8)
and &h00FF0000)
or _
24 (((c)
shr 8)
and &h0000FF00)
or ((c)
shl 24))
32 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_
33 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_
34 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_
35 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_
36 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_
37 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,_
38 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,_
39 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 _
44 &h00000000UL, &h00003080UL, &h000E2080UL, &h03C82080UL, &hFA082080UL, &h82082080UL _
49 dim as ubyte src(0
to 6)
53 dim as integer chars, extbytes, i
55 dst =
cast(
ubyte ptr, @lex.ctx->buffw )
58 do while( chars < LEX_MAXBUFFCHARS )
59 if(
eof( env.inf.num ) )
then
63 if(
get( #env.inf.num, , src(0) ) <> 0 )
then
71 if( extbytes > 0 )
then
72 if(
get( #env.inf.num, , src(1), extbytes ) <> 0 )
then
104 dim as ubyte src(0
to 6)
107 dim as ushort ptr dst
108 dim as integer chars, extbytes, i
110 dst =
cast(
ushort ptr, @lex.ctx->buffw )
113 do while( chars < LEX_MAXBUFFCHARS )
114 if(
eof( env.inf.num ) )
then
118 if(
get( #env.inf.num, , src(0) ) <> 0 )
then
126 if( extbytes > 0 )
then
127 if(
get( #env.inf.num, , src(1), extbytes ) <> 0 )
then
145 if( c > UTF16_MAX_BMP )
then
146 if( chars < LEX_MAXBUFFCHARS-1 )
then
147 *dst = (c
shr UTF16_HALFSHIFT) + UTF16_SUR_HIGH_START
152 c = (c
and UTF16_HALFMASK) + UTF16_SUR_LOW_START
166 dim as ubyte src(0
to 6)
170 dim as integer chars, extbytes, i
172 dst =
cast(
ulong ptr, @lex.ctx->buffw )
175 do while( chars < LEX_MAXBUFFCHARS )
176 if(
eof( env.inf.num ) )
then
180 if(
get( #env.inf.num, , src(0) ) <> 0 )
then
188 if( extbytes > 0 )
then
189 if(
get( #env.inf.num, , src(1), extbytes ) <> 0 )
then
219 dim as integer i, chars
223 dst =
cast(
ulong ptr, @lex.ctx->buffw )
238 if sizeof(
wstring) = 1
then
240 elseif sizeof(
wstring) = 2
then
243 #ifdef __FB_BIGENDIAN__
250 lex.ctx->bufflen = chars
251 lex.ctx->buffptrw = @lex.ctx->buffw
265 dst =
cast(
ubyte ptr, @lex.ctx->buffw )
268 do while( chars < LEX_MAXBUFFCHARS )
269 if(
eof( env.inf.num ) )
then
273 if(
get( #env.inf.num, , c ) <> 0 )
then
279 if( c >= UTF16_SUR_HIGH_START )
then
280 if( c <= UTF16_SUR_HIGH_END )
then
281 if(
get( #env.inf.num, , c ) <> 0 )
then
302 if(
get( #env.inf.num, , lex.ctx->buffw ) = 0 )
then
303 function = cunsg(
seek( env.inf.num ) - lex.ctx->filepos) \
len(
ushort )
317 dst =
cast(
ulong ptr, @lex.ctx->buffw )
320 do while( chars < LEX_MAXBUFFCHARS )
321 if(
eof( env.inf.num ) )
then
325 if(
get( #env.inf.num, , c ) <> 0 )
then
331 if( wc >= UTF16_SUR_HIGH_START )
then
332 if( wc <= UTF16_SUR_HIGH_END )
then
333 if(
get( #env.inf.num, , c ) <> 0 )
then
337 wc = ((wc - UTF16_SUR_HIGH_START)
shl UTF16_HALFSHIFT) + _
338 (
cuint( c ) - UTF16_SUR_LOW_START) + UTF16_HALFBASE
355 dim as integer i, chars
359 dst =
cast(
ulong ptr, @lex.ctx->buffw )
374 if sizeof(
wstring) = 1
then
376 elseif sizeof(
wstring) = 2
then
379 #ifdef __FB_BIGENDIAN__
386 lex.ctx->bufflen = chars
387 lex.ctx->buffptrw = @lex.ctx->buffw
401 dst =
cast(
ubyte ptr, @lex.ctx->buffw )
404 do while( chars < LEX_MAXBUFFCHARS )
405 if(
eof( env.inf.num ) )
then
409 if(
get( #env.inf.num, , c ) <> 0 )
then
417 if( c >= UTF16_SUR_HIGH_START )
then
418 if( c <= UTF16_SUR_HIGH_END )
then
419 if(
get( #env.inf.num, , c ) <> 0 )
then
439 dim as ushort ptr dst
441 dim as integer i, chars
445 dst =
cast(
ushort ptr, @lex.ctx->buffw )
463 dst =
cast(
ulong ptr, @lex.ctx->buffw )
466 do while( chars < LEX_MAXBUFFCHARS )
467 if(
eof( env.inf.num ) )
then
471 if(
get( #env.inf.num, , c ) <> 0 )
then
478 if( wc >= UTF16_SUR_HIGH_START )
then
479 if( wc <= UTF16_SUR_HIGH_END )
then
480 if(
get( #env.inf.num, , c ) <> 0 )
then
484 wc = ((wc - UTF16_SUR_HIGH_START)
shl UTF16_HALFSHIFT) + _
485 (
cuint( U16_SWAP( c ) ) - UTF16_SUR_LOW_START) + UTF16_HALFBASE
509 if sizeof(
wstring) = 1
then
511 elseif sizeof(
wstring) = 2
then
514 #ifdef __FB_BIGENDIAN__
521 lex.ctx->bufflen = chars
522 lex.ctx->buffptrw = @lex.ctx->buffw
536 dst =
cast(
ubyte ptr, @lex.ctx->buffw )
539 do while( chars < LEX_MAXBUFFCHARS )
540 if(
eof( env.inf.num ) )
then
544 if(
get( #env.inf.num, , c ) <> 0 )
then
564 dim as ushort ptr dst
567 dst =
cast(
ushort ptr, @lex.ctx->buffw )
570 do while( chars < LEX_MAXBUFFCHARS )
571 if(
eof( env.inf.num ) )
then
575 if(
get( #env.inf.num, , c ) <> 0 )
then
580 if( c > UTF16_MAX_BMP )
then
581 if( chars < LEX_MAXBUFFCHARS-1 )
then
582 *dst = (c
shr UTF16_HALFSHIFT) + UTF16_SUR_HIGH_START
587 c = (c
and UTF16_HALFMASK) + UTF16_SUR_LOW_START
602 if(
get( #env.inf.num, , lex.ctx->buffw ) = 0 )
then
603 function = cunsg(
seek( env.inf.num ) - lex.ctx->filepos) \
len(
uinteger )
614 dim as integer i, chars
618 dst =
cast(
ulong ptr, @lex.ctx->buffw )
633 if sizeof(
wstring) = 1
then
635 elseif sizeof(
wstring) = 2
then
638 #ifdef __FB_BIGENDIAN__
645 lex.ctx->bufflen = chars
646 lex.ctx->buffptrw = @lex.ctx->buffw
660 dst =
cast(
ubyte ptr, @lex.ctx->buffw )
663 do while( chars < LEX_MAXBUFFCHARS )
664 if(
eof( env.inf.num ) )
then
668 if(
get( #env.inf.num, , c ) <> 0 )
then
690 dim as ushort ptr dst
693 dst =
cast(
ushort ptr, @lex.ctx->buffw )
696 do while( chars < LEX_MAXBUFFCHARS )
697 if(
eof( env.inf.num ) )
then
701 if(
get( #env.inf.num, , c ) <> 0 )
then
708 if( c > UTF16_MAX_BMP )
then
709 if( chars < LEX_MAXBUFFCHARS-1 )
then
710 *dst = (c
shr UTF16_HALFSHIFT) + UTF16_SUR_HIGH_START
715 c = (c
and UTF16_HALFMASK) + UTF16_SUR_LOW_START
731 dim as integer i, chars
735 dst =
cast(
ulong ptr, @lex.ctx->buffw )
757 if sizeof(
wstring) = 1
then
759 elseif sizeof(
wstring) = 2
then
762 #ifdef __FB_BIGENDIAN__
769 lex.ctx->bufflen = chars
770 lex.ctx->buffptrw = @lex.ctx->buffw