[ucdn] Update to Unicode 9.0.0
Fixes https://github.com/grigorig/ucdn/issues/12
This commit is contained in:
parent
f3f6c1ccbf
commit
08c08af2f9
|
@ -154,6 +154,12 @@ static const hb_script_t ucdn_script_translate[] =
|
||||||
HB_SCRIPT_MULTANI,
|
HB_SCRIPT_MULTANI,
|
||||||
HB_SCRIPT_OLD_HUNGARIAN,
|
HB_SCRIPT_OLD_HUNGARIAN,
|
||||||
HB_SCRIPT_SIGNWRITING,
|
HB_SCRIPT_SIGNWRITING,
|
||||||
|
HB_SCRIPT_ADLAM,
|
||||||
|
HB_SCRIPT_BHAIKSUKI,
|
||||||
|
HB_SCRIPT_MARCHEN,
|
||||||
|
HB_SCRIPT_NEWA,
|
||||||
|
HB_SCRIPT_OSAGE,
|
||||||
|
HB_SCRIPT_TANGUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
static hb_unicode_combining_class_t
|
static hb_unicode_combining_class_t
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
Contents of this directory are derived from UCDN:
|
Contents of this directory are derived from UCDN:
|
||||||
|
|
||||||
https://github.com/grigorig/ucdn
|
https://github.com/grigorig/ucdn
|
||||||
https://github.com/behdad/ucdn
|
|
||||||
|
|
||||||
The original README follows:
|
The original README follows:
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include "ucdn.h"
|
#include "ucdn.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -24,14 +25,19 @@ typedef struct {
|
||||||
unsigned char bidi_class;
|
unsigned char bidi_class;
|
||||||
unsigned char mirrored;
|
unsigned char mirrored;
|
||||||
unsigned char east_asian_width;
|
unsigned char east_asian_width;
|
||||||
unsigned char normalization_check;
|
|
||||||
unsigned char script;
|
unsigned char script;
|
||||||
|
unsigned char linebreak_class;
|
||||||
} UCDRecord;
|
} UCDRecord;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned short from, to;
|
unsigned short from, to;
|
||||||
} MirrorPair;
|
} MirrorPair;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned short from, to;
|
||||||
|
unsigned char type;
|
||||||
|
} BracketPair;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int start;
|
unsigned int start;
|
||||||
short count, index;
|
short count, index;
|
||||||
|
@ -108,6 +114,24 @@ static int compare_mp(const void *a, const void *b)
|
||||||
return mpa->from - mpb->from;
|
return mpa->from - mpb->from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int compare_bp(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
BracketPair *bpa = (BracketPair *)a;
|
||||||
|
BracketPair *bpb = (BracketPair *)b;
|
||||||
|
return bpa->from - bpb->from;
|
||||||
|
}
|
||||||
|
|
||||||
|
static BracketPair *search_bp(uint32_t code)
|
||||||
|
{
|
||||||
|
BracketPair bp = {0,0,2};
|
||||||
|
BracketPair *res;
|
||||||
|
|
||||||
|
bp.from = code;
|
||||||
|
res = bsearch(&bp, bracket_pairs, BIDI_BRACKET_LEN, sizeof(BracketPair),
|
||||||
|
compare_bp);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
static int hangul_pair_decompose(uint32_t code, uint32_t *a, uint32_t *b)
|
static int hangul_pair_decompose(uint32_t code, uint32_t *a, uint32_t *b)
|
||||||
{
|
{
|
||||||
int si = code - SBASE;
|
int si = code - SBASE;
|
||||||
|
@ -199,6 +223,42 @@ int ucdn_get_script(uint32_t code)
|
||||||
return get_ucd_record(code)->script;
|
return get_ucd_record(code)->script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ucdn_get_linebreak_class(uint32_t code)
|
||||||
|
{
|
||||||
|
return get_ucd_record(code)->linebreak_class;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ucdn_get_resolved_linebreak_class(uint32_t code)
|
||||||
|
{
|
||||||
|
const UCDRecord *record = get_ucd_record(code);
|
||||||
|
|
||||||
|
switch (record->linebreak_class)
|
||||||
|
{
|
||||||
|
case UCDN_LINEBREAK_CLASS_AI:
|
||||||
|
case UCDN_LINEBREAK_CLASS_SG:
|
||||||
|
case UCDN_LINEBREAK_CLASS_XX:
|
||||||
|
return UCDN_LINEBREAK_CLASS_AL;
|
||||||
|
|
||||||
|
case UCDN_LINEBREAK_CLASS_SA:
|
||||||
|
if (record->category == UCDN_GENERAL_CATEGORY_MC ||
|
||||||
|
record->category == UCDN_GENERAL_CATEGORY_MN)
|
||||||
|
return UCDN_LINEBREAK_CLASS_CM;
|
||||||
|
return UCDN_LINEBREAK_CLASS_AL;
|
||||||
|
|
||||||
|
case UCDN_LINEBREAK_CLASS_CJ:
|
||||||
|
return UCDN_LINEBREAK_CLASS_NS;
|
||||||
|
|
||||||
|
case UCDN_LINEBREAK_CLASS_CB:
|
||||||
|
return UCDN_LINEBREAK_CLASS_B2;
|
||||||
|
|
||||||
|
case UCDN_LINEBREAK_CLASS_NL:
|
||||||
|
return UCDN_LINEBREAK_CLASS_BK;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return record->linebreak_class;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ucdn_mirror(uint32_t code)
|
uint32_t ucdn_mirror(uint32_t code)
|
||||||
{
|
{
|
||||||
MirrorPair mp = {0};
|
MirrorPair mp = {0};
|
||||||
|
@ -217,6 +277,24 @@ uint32_t ucdn_mirror(uint32_t code)
|
||||||
return res->to;
|
return res->to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t ucdn_paired_bracket(uint32_t code)
|
||||||
|
{
|
||||||
|
BracketPair *res = search_bp(code);
|
||||||
|
if (res == NULL)
|
||||||
|
return code;
|
||||||
|
else
|
||||||
|
return res->to;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ucdn_paired_bracket_type(uint32_t code)
|
||||||
|
{
|
||||||
|
BracketPair *res = search_bp(code);
|
||||||
|
if (res == NULL)
|
||||||
|
return UCDN_BIDI_PAIRED_BRACKET_TYPE_NONE;
|
||||||
|
else
|
||||||
|
return res->type;
|
||||||
|
}
|
||||||
|
|
||||||
int ucdn_decompose(uint32_t code, uint32_t *a, uint32_t *b)
|
int ucdn_decompose(uint32_t code, uint32_t *a, uint32_t *b)
|
||||||
{
|
{
|
||||||
const unsigned short *rec;
|
const unsigned short *rec;
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#ifndef UCDN_H
|
#ifndef UCDN_H
|
||||||
#define UCDN_H
|
#define UCDN_H
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
|
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__MINGW32__)
|
||||||
# define HB_BEGIN_VISIBILITY _Pragma ("GCC visibility push(hidden)")
|
# define HB_BEGIN_VISIBILITY _Pragma ("GCC visibility push(hidden)")
|
||||||
# define HB_END_VISIBILITY _Pragma ("GCC visibility pop")
|
# define HB_END_VISIBILITY _Pragma ("GCC visibility pop")
|
||||||
|
@ -58,6 +60,7 @@ typedef unsigned __int64 uint64_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define UCDN_EAST_ASIAN_F 0
|
#define UCDN_EAST_ASIAN_F 0
|
||||||
#define UCDN_EAST_ASIAN_H 1
|
#define UCDN_EAST_ASIAN_H 1
|
||||||
#define UCDN_EAST_ASIAN_W 2
|
#define UCDN_EAST_ASIAN_W 2
|
||||||
|
@ -197,6 +200,53 @@ typedef unsigned __int64 uint64_t;
|
||||||
#define UCDN_SCRIPT_MULTANI 129
|
#define UCDN_SCRIPT_MULTANI 129
|
||||||
#define UCDN_SCRIPT_OLD_HUNGARIAN 130
|
#define UCDN_SCRIPT_OLD_HUNGARIAN 130
|
||||||
#define UCDN_SCRIPT_SIGNWRITING 131
|
#define UCDN_SCRIPT_SIGNWRITING 131
|
||||||
|
#define UCDN_SCRIPT_ADLAM 132
|
||||||
|
#define UCDN_SCRIPT_BHAIKSUKI 133
|
||||||
|
#define UCDN_SCRIPT_MARCHEN 134
|
||||||
|
#define UCDN_SCRIPT_NEWA 135
|
||||||
|
#define UCDN_SCRIPT_OSAGE 136
|
||||||
|
#define UCDN_SCRIPT_TANGUT 137
|
||||||
|
|
||||||
|
#define UCDN_LINEBREAK_CLASS_OP 0
|
||||||
|
#define UCDN_LINEBREAK_CLASS_CL 1
|
||||||
|
#define UCDN_LINEBREAK_CLASS_CP 2
|
||||||
|
#define UCDN_LINEBREAK_CLASS_QU 3
|
||||||
|
#define UCDN_LINEBREAK_CLASS_GL 4
|
||||||
|
#define UCDN_LINEBREAK_CLASS_NS 5
|
||||||
|
#define UCDN_LINEBREAK_CLASS_EX 6
|
||||||
|
#define UCDN_LINEBREAK_CLASS_SY 7
|
||||||
|
#define UCDN_LINEBREAK_CLASS_IS 8
|
||||||
|
#define UCDN_LINEBREAK_CLASS_PR 9
|
||||||
|
#define UCDN_LINEBREAK_CLASS_PO 10
|
||||||
|
#define UCDN_LINEBREAK_CLASS_NU 11
|
||||||
|
#define UCDN_LINEBREAK_CLASS_AL 12
|
||||||
|
#define UCDN_LINEBREAK_CLASS_HL 13
|
||||||
|
#define UCDN_LINEBREAK_CLASS_ID 14
|
||||||
|
#define UCDN_LINEBREAK_CLASS_IN 15
|
||||||
|
#define UCDN_LINEBREAK_CLASS_HY 16
|
||||||
|
#define UCDN_LINEBREAK_CLASS_BA 17
|
||||||
|
#define UCDN_LINEBREAK_CLASS_BB 18
|
||||||
|
#define UCDN_LINEBREAK_CLASS_B2 19
|
||||||
|
#define UCDN_LINEBREAK_CLASS_ZW 20
|
||||||
|
#define UCDN_LINEBREAK_CLASS_CM 21
|
||||||
|
#define UCDN_LINEBREAK_CLASS_WJ 22
|
||||||
|
#define UCDN_LINEBREAK_CLASS_H2 23
|
||||||
|
#define UCDN_LINEBREAK_CLASS_H3 24
|
||||||
|
#define UCDN_LINEBREAK_CLASS_JL 25
|
||||||
|
#define UCDN_LINEBREAK_CLASS_JV 26
|
||||||
|
#define UCDN_LINEBREAK_CLASS_JT 27
|
||||||
|
#define UCDN_LINEBREAK_CLASS_RI 28
|
||||||
|
#define UCDN_LINEBREAK_CLASS_AI 29
|
||||||
|
#define UCDN_LINEBREAK_CLASS_BK 30
|
||||||
|
#define UCDN_LINEBREAK_CLASS_CB 31
|
||||||
|
#define UCDN_LINEBREAK_CLASS_CJ 32
|
||||||
|
#define UCDN_LINEBREAK_CLASS_CR 33
|
||||||
|
#define UCDN_LINEBREAK_CLASS_LF 34
|
||||||
|
#define UCDN_LINEBREAK_CLASS_NL 35
|
||||||
|
#define UCDN_LINEBREAK_CLASS_SA 36
|
||||||
|
#define UCDN_LINEBREAK_CLASS_SG 37
|
||||||
|
#define UCDN_LINEBREAK_CLASS_SP 38
|
||||||
|
#define UCDN_LINEBREAK_CLASS_XX 39
|
||||||
|
|
||||||
#define UCDN_GENERAL_CATEGORY_CC 0
|
#define UCDN_GENERAL_CATEGORY_CC 0
|
||||||
#define UCDN_GENERAL_CATEGORY_CF 1
|
#define UCDN_GENERAL_CATEGORY_CF 1
|
||||||
|
@ -253,6 +303,10 @@ typedef unsigned __int64 uint64_t;
|
||||||
#define UCDN_BIDI_CLASS_FSI 21
|
#define UCDN_BIDI_CLASS_FSI 21
|
||||||
#define UCDN_BIDI_CLASS_PDI 22
|
#define UCDN_BIDI_CLASS_PDI 22
|
||||||
|
|
||||||
|
#define UCDN_BIDI_PAIRED_BRACKET_TYPE_OPEN 0
|
||||||
|
#define UCDN_BIDI_PAIRED_BRACKET_TYPE_CLOSE 1
|
||||||
|
#define UCDN_BIDI_PAIRED_BRACKET_TYPE_NONE 2
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return version of the Unicode database.
|
* Return version of the Unicode database.
|
||||||
*
|
*
|
||||||
|
@ -301,6 +355,27 @@ int ucdn_get_bidi_class(uint32_t code);
|
||||||
*/
|
*/
|
||||||
int ucdn_get_script(uint32_t code);
|
int ucdn_get_script(uint32_t code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get unresolved linebreak class of a codepoint. This does not take
|
||||||
|
* rule LB1 of UAX#14 into account. See ucdn_get_resolved_linebreak_class()
|
||||||
|
* for resolved linebreak classes.
|
||||||
|
*
|
||||||
|
* @param code Unicode codepoint
|
||||||
|
* @return value according to UCDN_LINEBREAK_* and as defined in UAX#14.
|
||||||
|
*/
|
||||||
|
int ucdn_get_linebreak_class(uint32_t code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get resolved linebreak class of a codepoint. This resolves characters
|
||||||
|
* in the AI, SG, XX, SA and CJ classes according to rule LB1 of UAX#14.
|
||||||
|
* In addition the CB class is resolved as the equivalent B2 class and
|
||||||
|
* the NL class is resolved as the equivalent BK class.
|
||||||
|
*
|
||||||
|
* @param code Unicode codepoint
|
||||||
|
* @return value according to UCDN_LINEBREAK_* and as defined in UAX#14.
|
||||||
|
*/
|
||||||
|
int ucdn_get_resolved_linebreak_class(uint32_t code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if codepoint can be mirrored.
|
* Check if codepoint can be mirrored.
|
||||||
*
|
*
|
||||||
|
@ -318,6 +393,25 @@ int ucdn_get_mirrored(uint32_t code);
|
||||||
*/
|
*/
|
||||||
uint32_t ucdn_mirror(uint32_t code);
|
uint32_t ucdn_mirror(uint32_t code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paired bracket for a codepoint.
|
||||||
|
*
|
||||||
|
* @param code Unicode codepoint
|
||||||
|
* @return paired bracket codepoint or the original codepoint if no
|
||||||
|
* paired bracket character exists
|
||||||
|
*/
|
||||||
|
uint32_t ucdn_paired_bracket(uint32_t code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get paired bracket type for a codepoint.
|
||||||
|
*
|
||||||
|
* @param code Unicode codepoint
|
||||||
|
* @return value according to UCDN_BIDI_PAIRED_BRACKET_TYPE_* and as defined
|
||||||
|
* in UAX#9.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int ucdn_paired_bracket_type(uint32_t code);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pairwise canonical decomposition of a codepoint. This includes
|
* Pairwise canonical decomposition of a codepoint. This includes
|
||||||
* Hangul Jamo decomposition (see chapter 3.12 of the Unicode core
|
* Hangul Jamo decomposition (see chapter 3.12 of the Unicode core
|
||||||
|
@ -359,6 +453,8 @@ int ucdn_compat_decompose(uint32_t code, uint32_t *decomposed);
|
||||||
*/
|
*/
|
||||||
int ucdn_compose(uint32_t *code, uint32_t a, uint32_t b);
|
int ucdn_compose(uint32_t *code, uint32_t a, uint32_t b);
|
||||||
|
|
||||||
HB_END_HEADER
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue