1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
|
{-# LANGUAGE CPP, NoImplicitPrelude #-}
-- |
-- Module : Data.Text.ICU
-- Copyright : (c) 2010 Bryan O'Sullivan
--
-- License : BSD-style
-- Maintainer : bos@serpentine.com
-- Stability : experimental
-- Portability : GHC
--
-- Commonly used functions for Unicode, implemented as bindings to the
-- International Components for Unicode (ICU) libraries.
--
-- This module contains only the most commonly used types and
-- functions. Other modules in this package expose richer interfaces.
module Data.Text.ICU
(
-- * Data representation
-- $data
-- * Types
LocaleName(..)
-- * Locales
, availableLocales
-- * Boundary analysis
-- $break
, Breaker
, Break
, brkPrefix
, brkBreak
, brkSuffix
, brkStatus
, Line(..)
, Word(..)
, breakCharacter
, breakLine
, breakSentence
, breakWord
, breaks
, breaksRight
-- * Case mapping
, toCaseFold
, toLower
, toUpper
-- * Iteration
, CharIterator
, fromString
, fromText
, fromUtf8
-- * Normalization
-- $compat
-- ** Normalize unicode strings
, nfc, nfd, nfkc, nfkd, nfkcCasefold
-- ** Checks for normalization
, quickCheck, isNormalized
-- * String comparison
-- ** Normalization-sensitive string comparison
, CompareOption(..)
, compareUnicode
-- ** Locale-sensitive string collation
-- $collate
, Collator
, collator
, collatorWith
, collatorFromRules
, collatorFromRulesWith
, collate
, collateIter
, sortKey
, uca
-- * Regular expressions
, MatchOption(..)
, ParseError(errError, errLine, errOffset)
, Match
, Regex
, Regular
-- ** Construction
, regex
, regex'
-- ** Inspection
, pattern
-- ** Searching
, find
, findAll
-- ** Match groups
-- $group
, groupCount
, unfold
, span
, group
, prefix
, suffix
-- * Spoof checking
-- $spoof
, Spoof
, SpoofParams(..)
, S.SpoofCheck(..)
, S.RestrictionLevel(..)
, S.SpoofCheckResult(..)
-- ** Construction
, spoof
, spoofWithParams
, spoofFromSource
, spoofFromSerialized
-- ** String checking
, areConfusable
, spoofCheck
, getSkeleton
-- ** Configuration
, getChecks
, getAllowedLocales
, getRestrictionLevel
-- ** Persistence
, serialize
-- * Calendars
, Calendar, CalendarType(..), SystemTimeZoneType(..), CalendarField(..),
-- ** Construction
calendar,
-- ** Operations on calendars
roll, add, set1, set, get,
-- * Number formatting
NumberFormatter, numberFormatter, formatIntegral, formatIntegral', formatDouble, formatDouble',
-- * Date formatting
DateFormatter, FormatStyle(..), DateFormatSymbolType(..), standardDateFormatter, patternDateFormatter, dateSymbols, formatCalendar,
) where
import Data.Text.ICU.Break.Pure
import Data.Text.ICU.Calendar
import Data.Text.ICU.Collate.Pure
import Data.Text.ICU.DateFormatter
import Data.Text.ICU.Internal
import Data.Text.ICU.Iterator
import Data.Text.ICU.Locale
import Data.Text.ICU.Normalize2
import Data.Text.ICU.NumberFormatter
import Data.Text.ICU.Regex.Pure
import qualified Data.Text.ICU.Spoof as S
import Data.Text.ICU.Spoof.Pure
import Data.Text.ICU.Text
#if defined(__HADDOCK__)
import Data.Text.Foreign
import Data.Text (Text)
#endif
-- $data
--
-- The Haskell 'Text' type is implemented as an array in the Haskell
-- heap. This means that its location is not pinned; it may be copied
-- during a garbage collection pass. ICU, on the other hand, works
-- with strings that are allocated in the normal system heap and have
-- a fixed address.
--
-- To accommodate this need, these bindings use the functions from
-- "Data.Text.Foreign" to copy data between the Haskell heap and the
-- system heap. The copied strings are still managed automatically,
-- but the need to duplicate data does add some performance and memory
-- overhead.
-- $break
--
-- Text boundary analysis is the process of locating linguistic
-- boundaries while formatting and handling text. Examples of this
-- process include:
--
-- * Locating appropriate points to word-wrap text to fit within
-- specific margins while displaying or printing.
--
-- * Counting characters, words, sentences, or paragraphs.
--
-- * Making a list of the unique words in a document.
--
-- * Figuring out if a given range of text contains only whole words.
--
-- * Capitalizing the first letter of each word.
--
-- * Locating a particular unit of the text (For example, finding the
-- third word in the document).
--
-- The 'Breaker' type was designed to support these kinds of
-- tasks.
--
-- For the impure boundary analysis API (which is richer, but less
-- easy to use than the pure API), see the "Data.Text.ICU.Break"
-- module. The impure API supports some uses that may be less
-- efficient via the pure API, including:
--
-- * Locating the beginning of a word that the user has selected.
--
-- * Determining how far to move the text cursor when the user hits an
-- arrow key (Some characters require more than one position in the
-- text store and some characters in the text store do not display
-- at all).
-- $collate
--
-- For the impure collation API (which is richer, but less easy to
-- use than the pure API), see the "Data.Text.ICU.Collate"
-- module.
-- $group
--
-- Capturing groups are numbered starting from zero. Group zero is
-- always the entire matching text. Groups greater than zero contain
-- the text matching each capturing group in a regular expression.
-- $spoof
--
-- The 'Spoof' type performs security checks on visually confusable
-- (spoof) strings. For the impure spoof checking API (which is
-- richer, but less easy to use than the pure API), see the
-- "Data.Text.ICU.Spoof" module.
--
-- See <http://unicode.org/reports/tr36/ UTR #36> and
-- <http://unicode.org/reports/tr39/ UTS #39> for detailed information
-- about the underlying algorithms and databases used by these functions.
-- $formatting
--
-- You create a 'NumberFormat' with 'numberFormatter' according to a locale
-- and a choice of pre-defined formats. A 'NumberFormat' provides a formatting
-- facility that 'format's numbers
-- according to the chosen locale. Alternatively create and apply a 'NumberFormat'
-- in a single step with 'formatNumber'' (it may be faster to re-use a NumberFormat though).
-- See the section \"Patterns\" at <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/classDecimalFormat.html#Patterns>
-- for further details regarding pattern strings.
-- $compat
-- See module 'Data.Text.ICU.Normalization2' for the full interface which provides some compatibility with the former API.
|