38 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| #if __STDC_VERSION__ >= 199901L
 | |
| /* C99 type definitions */
 | |
| #	include <stdint.h>
 | |
| typedef uint32_t rune_t;
 | |
| #else
 | |
| /* Must hold at least 32b; see the C89 draft 2.2.4.2
 | |
|  * <http://jfxpt.com/library/c89-draft.html#2.2.4.2> */
 | |
| typedef unsigned long int rune_t;
 | |
| #endif
 | |
| #include <stddef.h> /* size_t */
 | |
| 
 | |
| /* Reverses the order of the bytes in the 32-bit value c. */
 | |
| rune_t swab32(rune_t c);
 | |
| 
 | |
| /* Returns the byte length of a valid UTF-8 rune. */
 | |
| size_t utf8_size(rune_t c);
 | |
| 
 | |
| /* Returns the UTF-32BE codepoint of the UTF-8 rune c. */
 | |
| rune_t utf8_to_utf32be(rune_t c);
 | |
| 
 | |
| /* Stores the UTF-8 rune c as bytes to the memory span s. s should point to a
 | |
|  * big enough memory span of chars in which to store c, a (possibly invalid)
 | |
|  * UTF-8 rune. Returns a pointer to the memory location after the last written
 | |
|  * byte. Returns NULL if n is not 0 and n is less than the number of bytes that
 | |
|  * will be written. */
 | |
| char *utf8_to_chars(rune_t c, char *s, size_t n);
 | |
| 
 | |
| /* Returns the UTF-8 encoding of the UTF-32BE codepoint c. m is the minimum
 | |
|  * amount of bytes into which to encode the codepoint c. If m is greater than
 | |
|  * 0, this function may return overlong-encoded UTF-8. */
 | |
| rune_t utf32be_to_utf8(rune_t c, size_t m);
 | |
| 
 | |
| /* Returns the UTF-32BE codepoint of the UTF-32LE codepoint c. */
 | |
| rune_t utf32be_to_utf32le(rune_t c);
 | |
| 
 | |
| /* Returns the UTF-32LE codepoint of the UTF-32BE codepoint c. */
 | |
| rune_t utf32le_to_utf32be(rune_t c);
 |