text-icu 0.1 → 0.2.0.0
raw patch · 8 files changed
+223/−29 lines, 8 files
Files
- Data/Text/ICU/Converter.hs +16/−16
- Data/Text/ICU/Converter/Internal.hs +1/−1
- Data/Text/ICU/Error.hsc +4/−0
- Data/Text/ICU/Error/Internal.hs +1/−1
- Data/Text/ICU/Normalizer.hsc +9/−4
- cbits/text_icu.c +128/−3
- include/hs_text_icu.h +54/−0
- text-icu.cabal +10/−4
Data/Text/ICU/Converter.hs view
@@ -181,55 +181,55 @@ then return [] else mapM ((peekCString =<<) . handleError . ucnv_getAlias ptr) [0..count-1] -foreign import ccall unsafe "unicode/ucnv.h ucnv_open_4_0" ucnv_open+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_open" ucnv_open :: CString -> Ptr UErrorCode -> IO (Ptr UConverter) -foreign import ccall unsafe "unicode/ucnv.h &ucnv_close_4_0" ucnv_close+foreign import ccall unsafe "hs_text_icu.h &__hs_ucnv_close" ucnv_close :: FunPtr (Ptr UConverter -> IO ()) foreign import ccall unsafe "__get_max_bytes_for_string" max_bytes_for_string :: Ptr UConverter -> CInt -> CInt -foreign import ccall unsafe "unicode/ucnv.h ucnv_toUChars_4_0" ucnv_toUChars+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_toUChars" ucnv_toUChars :: Ptr UConverter -> Ptr UChar -> Int32 -> CString -> Int32 -> Ptr UErrorCode -> IO Int32 -foreign import ccall unsafe "unicode/ucnv.h ucnv_fromUChars_4_0" ucnv_fromUChars+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_fromUChars" ucnv_fromUChars :: Ptr UConverter -> CString -> Int32 -> Ptr UChar -> Int32 -> Ptr UErrorCode -> IO Int32 -foreign import ccall unsafe "unicode/ucnv.h ucnv_compareNames_4_0" ucnv_compareNames+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_compareNames" ucnv_compareNames :: CString -> CString -> IO CInt -foreign import ccall unsafe "unicode/ucnv.h ucnv_getDefaultName_4_0" ucnv_getDefaultName+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_getDefaultName" ucnv_getDefaultName :: IO CString -foreign import ccall unsafe "unicode/ucnv.h ucnv_setDefaultName_4_0" ucnv_setDefaultName+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_setDefaultName" ucnv_setDefaultName :: CString -> IO () -foreign import ccall unsafe "unicode/ucnv.h ucnv_countAvailable_4_0" ucnv_countAvailable+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_countAvailable" ucnv_countAvailable :: Int32 -foreign import ccall unsafe "unicode/ucnv.h ucnv_getAvailableName_4_0" ucnv_getAvailableName+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_getAvailableName" ucnv_getAvailableName :: Int32 -> IO CString -foreign import ccall unsafe "unicode/ucnv.h ucnv_countAliases_4_0" ucnv_countAliases+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_countAliases" ucnv_countAliases :: CString -> IO Word16 -foreign import ccall unsafe "unicode/ucnv.h ucnv_getAlias_4_0" ucnv_getAlias+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_getAlias" ucnv_getAlias :: CString -> Word16 -> Ptr UErrorCode -> IO CString -foreign import ccall unsafe "unicode/ucnv.h ucnv_countStandards_4_0" ucnv_countStandards+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_countStandards" ucnv_countStandards :: Word16 -foreign import ccall unsafe "unicode/ucnv.h ucnv_getStandard_4_0" ucnv_getStandard+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_getStandard" ucnv_getStandard :: Word16 -> Ptr UErrorCode -> IO CString -foreign import ccall unsafe "unicode/ucnv.h ucnv_usesFallback_4_0" ucnv_usesFallback+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_usesFallback" ucnv_usesFallback :: Ptr UConverter -> IO UBool -foreign import ccall unsafe "unicode/ucnv.h ucnv_setFallback_4_0" ucnv_setFallback+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_setFallback" ucnv_setFallback :: Ptr UConverter -> UBool -> IO () -foreign import ccall unsafe "unicode/ucnv.h ucnv_isAmbiguous_4_0" ucnv_isAmbiguous+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_isAmbiguous" ucnv_isAmbiguous :: Ptr UConverter -> IO UBool
Data/Text/ICU/Converter/Internal.hs view
@@ -46,5 +46,5 @@ withConverter cnv $ \ptr -> peekCString =<< handleError (ucnv_getName ptr) -foreign import ccall unsafe "unicode/ucnv.h ucnv_getName_4_0" ucnv_getName+foreign import ccall unsafe "hs_text_icu.h __hs_ucnv_getName" ucnv_getName :: Ptr UConverter -> Ptr UErrorCode -> IO CString
Data/Text/ICU/Error.hsc view
@@ -145,6 +145,10 @@ u_IDNA_DOMAIN_NAME_TOO_LONG_ERROR ) where +#ifdef mingw32_HOST_OS+#define U_HAVE_INTTYPES_H 1+#endif+ #include <unicode/utypes.h> import Data.Text.ICU.Error.Internal
Data/Text/ICU/Error/Internal.hs view
@@ -76,5 +76,5 @@ errorName code = unsafePerformIO $ peekCString (u_errorName (fromErrorCode code)) -foreign import ccall unsafe "unicode/utypes.h u_errorName_4_0" u_errorName+foreign import ccall unsafe "hs_text_icu.h __hs_u_errorName" u_errorName :: UErrorCode -> CString
Data/Text/ICU/Normalizer.hsc view
@@ -32,6 +32,10 @@ , compare ) where +#ifdef mingw32_HOST_OS+#define U_HAVE_INTTYPES_H 1+#endif+ #include <unicode/unorm.h> import Control.Exception (throw)@@ -191,6 +195,7 @@ type UNormalizationCheckResult = CInt +-- | Result of a fast normalization check using 'quickCheck'. data NormalizationCheckResult = No -- ^ Text is not normalized. | Perhaps -- ^ It cannot be determined whether text is in normalized @@ -282,17 +287,17 @@ unorm_compare aptr (fromIntegral alen) bptr (fromIntegral blen) (foldCompareOptions opts) -foreign import ccall unsafe "unicode/unorm.h unorm_compare_4_0" unorm_compare+foreign import ccall unsafe "hs_text_icu.h __hs_unorm_compare" unorm_compare :: Ptr UChar -> Int32 -> Ptr UChar -> Int32 -> Word32 -> Ptr UErrorCode -> IO Int32 -foreign import ccall unsafe "unicode/unorm.h unorm_quickCheck_4_0" unorm_quickCheck+foreign import ccall unsafe "hs_text_icu.h __hs_unorm_quickCheck" unorm_quickCheck :: Ptr UChar -> Int32 -> UNormalizationMode -> Ptr UErrorCode -> IO UNormalizationCheckResult -foreign import ccall unsafe "unicode/unorm.h unorm_isNormalized_4_0" unorm_isNormalized+foreign import ccall unsafe "hs_text_icu.h __hs_unorm_isNormalized" unorm_isNormalized :: Ptr UChar -> Int32 -> UNormalizationMode -> Ptr UErrorCode -> IO UBool -foreign import ccall unsafe "unicode/unorm.h unorm_normalize_4_0" unorm_normalize+foreign import ccall unsafe "hs_text_icu.h __hs_unorm_normalize" unorm_normalize :: Ptr UChar -> Int32 -> UNormalizationMode -> Int32 -> Ptr UChar -> Int32 -> Ptr UErrorCode -> IO Int32
cbits/text_icu.c view
@@ -1,8 +1,133 @@-#include "unicode/ucnv.h"--#include <stdint.h>+#include "hs_text_icu.h" int __get_max_bytes_for_string(UConverter *cnv, int src_length) { return UCNV_GET_MAX_BYTES_FOR_STRING(src_length, ucnv_getMaxCharSize(cnv));+}++const char *__hs_u_errorName(UErrorCode code)+{+ return u_errorName(code);+}++const char *__hs_ucnv_getName(const UConverter *converter, UErrorCode *err)+{+ return ucnv_getName(converter, err);+}++UConverter* __hs_ucnv_open(const char *converterName, UErrorCode *err)+{+ return ucnv_open(converterName, err);+}++void __hs_ucnv_close(UConverter * converter)+{+ ucnv_close(converter);+}++int32_t __hs_ucnv_toUChars(UConverter *cnv, UChar *dest, int32_t destCapacity,+ const char *src, int32_t srcLength,+ UErrorCode *pErrorCode)+{+ return ucnv_toUChars(cnv, dest, destCapacity, src, srcLength, pErrorCode);+}++int32_t __hs_ucnv_fromUChars(UConverter *cnv, char *dest, int32_t destCapacity,+ const UChar *src, int32_t srcLength,+ UErrorCode *pErrorCode)+{+ return ucnv_fromUChars(cnv, dest, destCapacity, src, srcLength, pErrorCode);+}++int __hs_ucnv_compareNames(const char *name1, const char *name2)+{+ return ucnv_compareNames(name1, name2);+}++const char *__hs_ucnv_getDefaultName(void)+{+ return ucnv_getDefaultName();+}++void __hs_ucnv_setDefaultName(const char *name)+{+ ucnv_setDefaultName(name);+}++int32_t __hs_ucnv_countAvailable(void)+{+ return ucnv_countAvailable();+}++const char* __hs_ucnv_getAvailableName(int32_t n)+{+ return ucnv_getAvailableName(n);+}++uint16_t __hs_ucnv_countAliases(const char *alias, UErrorCode *pErrorCode)+{+ return ucnv_countAliases(alias, pErrorCode);+}++const char *__hs_ucnv_getAlias(const char *alias, uint16_t n,+ UErrorCode *pErrorCode)+{+ return ucnv_getAlias(alias, n, pErrorCode);+}++uint16_t __hs_ucnv_countStandards(void)+{+ return ucnv_countStandards();+}++const char *__hs_ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode)+{+ return ucnv_getStandard(n, pErrorCode);+}++UBool __hs_ucnv_usesFallback(const UConverter *cnv)+{+ return ucnv_usesFallback(cnv);+}++void __hs_ucnv_setFallback(UConverter *cnv, UBool usesFallback)+{+ ucnv_setFallback(cnv, usesFallback);+}++UBool __hs_ucnv_isAmbiguous(const UConverter *cnv)+{+ return ucnv_isAmbiguous(cnv);+}++int32_t __hs_unorm_compare(const UChar *s1, int32_t length1,+ const UChar *s2, int32_t length2,+ uint32_t options,+ UErrorCode *pErrorCode)+{+ return unorm_compare(s1, length1, s2, length2, options, pErrorCode);+}++UNormalizationCheckResult __hs_unorm_quickCheck(const UChar *source,+ int32_t sourcelength,+ UNormalizationMode mode,+ UErrorCode *status)+{+ return unorm_quickCheck(source, sourcelength, mode, status);+}++UBool __hs_unorm_isNormalized(const UChar *src, int32_t srcLength,+ UNormalizationMode mode,+ UErrorCode *pErrorCode)+{+ return unorm_isNormalized(src, srcLength, mode, pErrorCode);+}++int32_t __hs_unorm_normalize(const UChar *source, int32_t sourceLength,+ UNormalizationMode mode, int32_t options,+ UChar *result, int32_t resultLength,+ UErrorCode *status)+{+ return unorm_normalize(source, sourceLength, mode, options, result,+ resultLength, status); }
+ include/hs_text_icu.h view
@@ -0,0 +1,54 @@+#ifdef WIN32+#define U_HAVE_INTTYPES_H 1+#endif++#include "unicode/utypes.h"+#include "unicode/ucnv.h"+#include "unicode/unorm.h"++#include <stdint.h>++/* ucnv.h */++int __get_max_bytes_for_string(UConverter *cnv, int src_length);+const char *__hs_u_errorName(UErrorCode code);+const char *__hs_ucnv_getName(const UConverter *converter, UErrorCode *err);+UConverter* __hs_ucnv_open(const char *converterName, UErrorCode *err);+void __hs_ucnv_close(UConverter * converter);+int32_t __hs_ucnv_toUChars(UConverter *cnv, UChar *dest, int32_t destCapacity,+ const char *src, int32_t srcLength,+ UErrorCode *pErrorCode);+int32_t __hs_ucnv_fromUChars(UConverter *cnv, char *dest, int32_t destCapacity,+ const UChar *src, int32_t srcLength,+ UErrorCode *pErrorCode);+int __hs_ucnv_compareNames(const char *name1, const char *name2);+const char *__hs_ucnv_getDefaultName(void);+void __hs_ucnv_setDefaultName(const char *name);+int32_t __hs_ucnv_countAvailable(void);+const char* __hs_ucnv_getAvailableName(int32_t n);+uint16_t __hs_ucnv_countAliases(const char *alias, UErrorCode *pErrorCode);+const char *__hs_ucnv_getAlias(const char *alias, uint16_t n,+ UErrorCode *pErrorCode);+uint16_t __hs_ucnv_countStandards(void);+const char *__hs_ucnv_getStandard(uint16_t n, UErrorCode *pErrorCode);+UBool __hs_ucnv_usesFallback(const UConverter *cnv);+void __hs_ucnv_setFallback(UConverter *cnv, UBool usesFallback);+UBool __hs_ucnv_isAmbiguous(const UConverter *cnv);++/* unorm.h */++int32_t __hs_unorm_compare(const UChar *s1, int32_t length1,+ const UChar *s2, int32_t length2,+ uint32_t options,+ UErrorCode *pErrorCode);+UNormalizationCheckResult __hs_unorm_quickCheck(const UChar *source,+ int32_t sourcelength,+ UNormalizationMode mode,+ UErrorCode *status);+UBool __hs_unorm_isNormalized(const UChar *src, int32_t srcLength,+ UNormalizationMode mode,+ UErrorCode *pErrorCode);+int32_t __hs_unorm_normalize(const UChar *source, int32_t sourceLength,+ UNormalizationMode mode, int32_t options,+ UChar *result, int32_t resultLength,+ UErrorCode *status);
text-icu.cabal view
@@ -1,18 +1,19 @@ name: text-icu-version: 0.1+version: 0.2.0.0 synopsis: Bindings to the ICU library description: Haskell bindings to the International Components for Unicode (ICU) libraries. These libraries provide robust and full-featured Unicode services on a wide variety of platforms. maintainer: Bryan O'Sullivan <bos@serpentine.com>-copyright: 2009 Bryan O'Sullivan+copyright: 2009, 2010 Bryan O'Sullivan category: Data, Text license: BSD3 license-file: LICENSE build-type: Simple cabal-version: >= 1.2-extra-source-files: README+extra-source-files:+ README include/hs_text_icu.h library build-depends: base < 5, bytestring, text@@ -28,7 +29,12 @@ Data.Text.ICU.Error.Internal Data.Text.ICU.Internal c-sources: cbits/text_icu.c- extra-libraries: icui18n icuuc icudata+ include-dirs: include+ extra-libraries: icuuc+ if os(mingw32)+ extra-libraries: icuin icudt+ else+ extra-libraries: icui18n icudata ghc-options: -Wall if impl(ghc >= 6.8)