text-icu 0.6.2.1 → 0.6.3.0
raw patch · 4 files changed
+52/−4 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Data.Text.ICU.Char: charFromFullName :: String -> Maybe Char
+ Data.Text.ICU.Char: charFromName :: String -> Maybe Char
- Data.Text.ICU: groupCount :: (Regular r) => r -> Int
+ Data.Text.ICU: groupCount :: Regular r => r -> Int
- Data.Text.ICU: pattern :: (Regular r) => r -> Text
+ Data.Text.ICU: pattern :: Regular r => r -> Text
- Data.Text.ICU.Char: property :: (Property p v) => p -> Char -> v
+ Data.Text.ICU.Char: property :: Property p v => p -> Char -> v
Files
- Data/Text/ICU/Char.hsc +42/−3
- cbits/text_icu.c +6/−0
- include/hs_text_icu.h +3/−0
- text-icu.cabal +1/−1
Data/Text/ICU/Char.hsc view
@@ -70,6 +70,8 @@ , blockCode , charFullName , charName+ , charFromFullName+ , charFromName , combiningClass , direction , property@@ -86,13 +88,14 @@ import Control.Exception (throw) import Data.Char (chr, ord) import Data.Int (Int32)-import Data.Text.ICU.Error (isFailure, u_BUFFER_OVERFLOW_ERROR)+import Data.Text.ICU.Error (isFailure, u_BUFFER_OVERFLOW_ERROR,+ u_INVALID_CHAR_FOUND) import Data.Text.ICU.Error.Internal (UErrorCode, withError) import Data.Text.ICU.Internal (UBool, UChar32, asBool) import Data.Text.ICU.Normalize.Internal (toNCR) import Data.Typeable (Typeable) import Data.Word (Word8)-import Foreign.C.String (CString, peekCStringLen)+import Foreign.C.String (CString, peekCStringLen, withCString) import Foreign.C.Types (CInt) import Foreign.Marshal.Alloc (allocaBytes) import Foreign.Ptr (Ptr)@@ -861,10 +864,42 @@ -- | Return the full name of a Unicode character. -- -- Compared to 'charName', this function gives each Unicode code point--- a unique name.+-- a unique extended name. Extended names are lowercase followed by an+-- uppercase hexadecimal number, within angle brackets. charFullName :: Char -> String charFullName = charName' (#const U_EXTENDED_CHAR_NAME) +-- | Find a Unicode character by its full name, and return its code+-- point value.+--+-- The name is matched exactly and completely.+--+-- A Unicode 1.0 name is matched only if it differs from the modern+-- name. Unicode names are all uppercase.+charFromName :: String -> Maybe Char+charFromName = charFromName' (#const U_UNICODE_CHAR_NAME)++-- | Find a Unicode character by its full or extended name, and return+-- its code point value.+--+-- The name is matched exactly and completely.+--+-- A Unicode 1.0 name is matched only if it differs from the modern+-- name.+--+-- Compared to 'charFromName', this function gives each Unicode code+-- point a unique extended name. Extended names are lowercase followed+-- by an uppercase hexadecimal number, within angle brackets.+charFromFullName :: String -> Maybe Char+charFromFullName = charFromName' (#const U_EXTENDED_CHAR_NAME)++charFromName' :: UCharNameChoice -> String -> Maybe Char+charFromName' choice name = unsafePerformIO . withCString name $ \ptr -> do+ (err,r) <- withError $ u_charFromName choice ptr+ return $! if err == u_INVALID_CHAR_FOUND || r == 0xffff+ then Nothing+ else Just $! chr (fromIntegral r)+ -- | Return the ISO 10646 comment for a character. -- -- If a character does not have an associated comment, the empty@@ -916,6 +951,10 @@ foreign import ccall unsafe "hs_text_icu.h __hs_u_charName" u_charName :: UChar32 -> UCharNameChoice -> CString -> Int32 -> Ptr UErrorCode -> IO Int32++foreign import ccall unsafe "hs_text_icu.h __hs_u_charFromName" u_charFromName+ :: UCharNameChoice -> CString -> Ptr UErrorCode+ -> IO UChar32 foreign import ccall unsafe "hs_text_icu.h __hs_u_getISOComment" u_getISOComment :: UChar32 -> CString -> Int32 -> Ptr UErrorCode -> IO Int32
cbits/text_icu.c view
@@ -350,6 +350,12 @@ return u_charName(code, nameChoice, buffer, bufferLength, pErrorCode); } +UChar32 __hs_u_charFromName(UCharNameChoice nameChoice, const char *name,+ UErrorCode *pErrorCode)+{+ return u_charFromName(nameChoice, name, pErrorCode);+}+ int32_t __hs_u_getISOComment(UChar32 c, char *dest, int32_t destCapacity, UErrorCode *pErrorCode) {
include/hs_text_icu.h view
@@ -51,6 +51,9 @@ int32_t __hs_u_charName(UChar32 code, UCharNameChoice nameChoice, char *buffer, int32_t bufferLength, UErrorCode *pErrorCode);+UChar32 __hs_u_charFromName(UCharNameChoice nameChoice,+ const char *name,+ UErrorCode *pErrorCode); int32_t __hs_u_getISOComment(UChar32 c, char *dest, int32_t destCapacity, UErrorCode *pErrorCode); int32_t __hs_u_getIntPropertyValue(UChar32 c, UProperty which);
text-icu.cabal view
@@ -1,5 +1,5 @@ name: text-icu-version: 0.6.2.1+version: 0.6.3.0 synopsis: Bindings to the ICU library homepage: http://bitbucket.org/bos/text-icu bug-reports: http://bitbucket.org/bos/text-icu/issues