This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red/System [] | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; function utf8-to-cps (cps = codepoints) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
; This function decodes UTF-8 information supplied as bytes in argument u | |
; and uses the argument res to store the array of codepoints | |
; (integers >= 0 and < 10FFFFh); the space for this array should have been | |
; allocated by the caller; an upper limit for the size of the array in bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [] | |
utf8-to-cps: func [ ; yields a block of integers >= 0 and < 1114112 | |
; coding errors are skipped | |
u [binary!] | |
/local bcp b1 b2 b3 b4 | |
][ | |
bcp: make block! length? u ; overestimated | |
while [not tail? u][ | |
b1: u/1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red/System [] | |
utf8-to-codepoint: func [ ; yields an integer >= 0 and < 1114112, or -1 | |
u [c-string!] ; should have length 1 to 4 | |
/local b1 b2 b3 b4 | |
][ | |
either 1 = length? u | |
[ | |
b1: as-integer u/1 | |
either b1 < 128 [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [ | |
Title: "Red/System lexical analysis" | |
Date: 1-Jul-2011 | |
Name: "Reds lexer" | |
Type: none | |
Version: 1.0.0 | |
File: %/G/Projects/Common/RED/red-system/sources/reds-lexer/reds-lexer.r | |
Home: http://users.telenet.be/rwmeijer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REBOL [ | |
Title: "Grammar for Red/System lexical analysis" | |
Date: 1-Jul-2011 | |
Name: "reds-lex-grammar" | |
Version: 1.0.0 | |
File: %/G/Projects/Common/RED/red-system/sources/reds-lexer/reds-lex-grammar.r | |
Home: http://users.telenet.be/rwmeijer | |
Author: "Rudolf W. Meijer" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red/System [ | |
Title: "String functions" | |
Purpose: {proposed library functions for c-string manipulation} | |
Author: "Rudolf W. MEIJER" | |
File: %stringf.reds | |
Version: 0.1.0 | |
Date: 27-May-2011 | |
] | |
#import [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red/System [ | |
Title: "Form" | |
Purpose: {formats an integer in a c-string, as signed decimal or as hex} | |
Author: "Rudolf W. MEIJER" | |
File: %form-number.reds | |
Version: 0.7 | |
Date: 27-May-2011 | |
Notes: {Improved version, not final} | |
] |
NewerOlder