~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to ext/json/ext/parser/unicode.h

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-06-06 11:58:24 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20070606115824-qzldkdwq3dvfpf84
Tags: 1.9.0+20070606-1
* new upstream snapshot. (2006-06-06)
* updated debian/generated-incs/* files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#ifndef _PARSER_UNICODE_H_
 
3
#define _PARSER_UNICODE_H_
 
4
 
 
5
#include "ruby.h"
 
6
 
 
7
typedef unsigned long   UTF32;  /* at least 32 bits */
 
8
typedef unsigned short  UTF16;  /* at least 16 bits */
 
9
typedef unsigned char   UTF8;   /* typically 8 bits */
 
10
 
 
11
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
 
12
#define UNI_MAX_BMP (UTF32)0x0000FFFF
 
13
#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
 
14
#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
 
15
#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
 
16
 
 
17
#define UNI_SUR_HIGH_START  (UTF32)0xD800
 
18
#define UNI_SUR_HIGH_END    (UTF32)0xDBFF
 
19
#define UNI_SUR_LOW_START   (UTF32)0xDC00
 
20
#define UNI_SUR_LOW_END     (UTF32)0xDFFF
 
21
 
 
22
static const int halfShift  = 10; /* used for shifting by 10 bits */
 
23
 
 
24
static const UTF32 halfBase = 0x0010000UL;
 
25
static const UTF32 halfMask = 0x3FFUL;
 
26
 
 
27
typedef enum {
 
28
        conversionOK = 0,       /* conversion successful */
 
29
        sourceExhausted,        /* partial character in source, but hit end */
 
30
        targetExhausted,        /* insuff. room in target for conversion */
 
31
        sourceIllegal           /* source sequence is illegal/malformed */
 
32
} ConversionResult;
 
33
 
 
34
typedef enum {
 
35
        strictConversion = 0,
 
36
        lenientConversion
 
37
} ConversionFlags;
 
38
 
 
39
char *JSON_convert_UTF16_to_UTF8 (
 
40
    VALUE buffer,
 
41
    char *source,
 
42
    char *sourceEnd,
 
43
                ConversionFlags flags);
 
44
 
 
45
#ifndef RARRAY_PTR
 
46
#define RARRAY_PTR(ARRAY) RARRAY(ARRAY)->ptr
 
47
#endif
 
48
#ifndef RARRAY_LEN
 
49
#define RARRAY_LEN(ARRAY) RARRAY(ARRAY)->len
 
50
#endif
 
51
#ifndef RSTRING_PTR
 
52
#define RSTRING_PTR(string) RSTRING(string)->ptr
 
53
#endif
 
54
#ifndef RSTRING_LEN
 
55
#define RSTRING_LEN(string) RSTRING(string)->len
 
56
#endif
 
57
 
 
58
#endif