Skip to content

Commit

Permalink
icu: Add scripts support
Browse files Browse the repository at this point in the history
  • Loading branch information
wismill committed Jun 15, 2024
1 parent a20ed73 commit 08ffbbf
Show file tree
Hide file tree
Showing 4 changed files with 322 additions and 0 deletions.
26 changes: 26 additions & 0 deletions experimental/icu/cbits/icu.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#include <unicode/utypes.h>
#include <unicode/uchar.h>
#include <unicode/uscript.h>
#include "icu.h"

void __hs_u_getUnicodeVersion(UVersionInfo versionArray) {
u_getUnicodeVersion(versionArray);
}

/*******************************************************************************
* Names
******************************************************************************/

int32_t __hs_u_charName( UChar32 codepoint
, UCharNameChoice nameChoice
, char * buffer
Expand All @@ -21,3 +26,24 @@ void __hs_u_charAge( UChar32 c, UVersionInfo versionArray ) {
int8_t __hs_u_charType(UChar32 c) {
return u_charType(c);
}

/*******************************************************************************
* Scripts
******************************************************************************/

UScriptCode __hs_uscript_getScript(UChar32 codepoint) {
UErrorCode err = U_ZERO_ERROR;
return uscript_getScript(codepoint, &err);
}

int32_t __hs_uscript_getScriptExtensions
( UChar32 codepoint
, UScriptCode * scripts
, int32_t capacity ) {
UErrorCode err = U_ZERO_ERROR;
return uscript_getScriptExtensions(codepoint, scripts, capacity, &err);
}

const char * __hs_uscript_getShortName(UScriptCode scriptCode) {
return uscript_getShortName(scriptCode);
}
18 changes: 18 additions & 0 deletions experimental/icu/cbits/icu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@

#include <unicode/utypes.h>
#include <unicode/uchar.h>
#include <unicode/uscript.h>

void __hs_u_getUnicodeVersion(UVersionInfo versionArray);

/*******************************************************************************
* Names
******************************************************************************/

int32_t __hs_u_charName( UChar32 codepoint
, UCharNameChoice nameChoice
, char * buffer
Expand All @@ -19,4 +24,17 @@ static const int __hs_U_MAX_VERSION_LENGTH = U_MAX_VERSION_LENGTH;

int8_t __hs_u_charType(UChar32 c);

/*******************************************************************************
* Scripts
******************************************************************************/

UScriptCode __hs_uscript_getScript(UChar32 codepoint);

int32_t __hs_uscript_getScriptExtensions
( UChar32 codepoint
, UScriptCode * scripts
, int32_t capacity );

const char * __hs_uscript_getShortName(UScriptCode scriptCode);

#endif
1 change: 1 addition & 0 deletions experimental/icu/icu.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ library
ICU.Char
ICU.Names
ICU.Names.Text
ICU.Scripts
hs-source-dirs: lib
build-depends:
base >= 4.7 && < 4.21
Expand Down
Loading

0 comments on commit 08ffbbf

Please sign in to comment.