h)m      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ 2.0.2  2022 Julian OspaldMIT"Julian Ospald  experimentalportable Safe-Inferred ( O os-stringTotal conversion to char.W  os-stringO(n). Construct a new ShortByteString from a CWString. The resulting ShortByteString' is an immutable copy of the original CWString4, and is managed on the Haskell heap. The original CWString must be null terminated.X  os-stringO(n). Construct a new ShortByteString from a  CWStringLen. The resulting ShortByteString& is an immutable copy of the original  CWStringLen. The ShortByteString is a normal Haskell value and will be managed on the Haskell heap.Y  os-stringO(n) construction. Use a ShortByteString. with a function requiring a null-terminated CWString. The CWString is a copy and will be freed automatically; it must not be stored or used after the subcomputation finishes.Z  os-stringO(n) construction. Use a ShortByteString with a function requiring a  CWStringLen . As for  useAsCWString, this function makes a copy of the original ShortByteString. It must not be stored or used after the subcomputation finishes.[  os-stringO(n) construction. Use a ShortByteString with a function requiring a  CWStringLen . As for  useAsCWString, this function makes a copy of the original ShortByteString. It must not be stored or used after the subcomputation finishes.c os-stringEncode Word16 as little-endian.e os-string!Decode Word16 from little-endian.j os-stringGiven the maximum size needed and a function to make the contents of a ShortByteString, createAndTrim makes the . The generating function is required to return the actual final size (<= the maximum size) and the result value. The resulting byte array is realloced to this size.n os-stringReturns the length of the substring matching, not the index. If no match, returns 0.c os-stringWord8 index (not Word16)d os-string Word8 indexe os-stringWord8 index (not Word16)r os-stringarray 1 os-stringoffset for array 1 os-stringarray 2 os-stringoffset for array 2 os-stringlength to compare os-string like memcmp*IJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr*MNOPQKLIJRSTUVWXYZ[\]^_`abcdefghijklmnopqr/(c) Duncan Coutts 2012-2013, Julian Ospald 2022 BSD-stylehasufell@posteo.destableghc only Safe-Inferredg  s !"#567$&'%()*+,-./0123489:;<>=?@ABCDEFGH  s !"#567$&'%()*+,-./0123489:;<>=?@ABCDEFGH 2022 Julian OspaldMIT"Julian Ospald  experimentalportable Safe-Inferred (?8t os-stringO(1) Convert a  into a u os-stringO(n). Convert a list into a v os-stringO(n) . Convert a  into a list.w os-string This is like , but the number of , not .x os-stringO(n)! Append a Word16 to the end of a "Note: copies the entire byte arrayy os-stringO(n) y is analogous to (:) for lists."Note: copies the entire byte arrayz os-stringO(1) Extract the last element of a ShortByteString, which must be finite and at least one Word16. An exception will be thrown in the case of an empty ShortByteString.{ os-stringO(n) Extract the elements after the head of a ShortByteString, which must at least one Word16. An exception will be thrown in the case of an empty ShortByteString."Note: copies the entire byte array| os-stringO(n) Extract the head and tail of a ByteString, returning Nothing if it is empty.} os-stringO(n) Extract first two elements and the rest of a ByteString, returning Nothing if it is shorter than two elements.~ os-stringO(1) Extract the first element of a ShortByteString, which must be at least one Word16. An exception will be thrown in the case of an empty ShortByteString. os-stringO(n) Return all the elements of a  except the last one. An exception will be thrown in the case of an empty ShortByteString."Note: copies the entire byte array os-stringO(n) Extract the  and z4 of a ByteString, returning Nothing if it is empty. os-stringO(n)  f xs- is the ShortByteString obtained by applying f to each element of xs. os-stringO(n)  xs% efficiently returns the elements of xs in reverse order. os-stringO(n) Applied to a predicate and a , $ determines if all elements of the  satisfy the predicate. os-stringO(n)* Applied to a predicate and a ByteString, # determines if any element of the  ByteString satisfies the predicate. os-stringO(n)  n x is a ByteString of length n with x2 the value of every element. The following holds: .replicate w c = unfoldr w (\u -> Just (u,u)) c os-stringO(n), where n# is the length of the result. The 0 function is analogous to the List 'unfoldr'.  builds a ShortByteString from a seed value. The function takes the element and returns 9 if it is done producing the ShortByteString or returns  (a,b), in which case, a& is the next byte in the string, and b* is the seed value for further production.=This function is not efficient/safe. It will build a list of [Word16]) and run the generator until it returns 7, otherwise recurse infinitely, then finally create a . Examples:  unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0 == pack [0, 1, 2, 3, 4, 5] os-stringO(n) Like ,  builds a ShortByteString from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than 1 when the maximum length of the result is known.The following equation relates  and : ,fst (unfoldrN n f s) == take n (unfoldr f s) os-stringO(n)  n, applied to a ShortByteString xs, returns the prefix of xs of length n, or xs itself if n >  xs."Note: copies the entire byte array os-stringO(1)  n xs is equivalent to  ( xs - n) xs . Takes n! elements from end of bytestring./takeEnd 3 "a\NULb\NULc\NULd\NULe\NULf\NULg\NUL""e\NULf\NULg\NUL"/takeEnd 0 "a\NULb\NULc\NULd\NULe\NULf\NULg\NUL"""takeEnd 4 "a\NULb\NULc\NUL""a\NULb\NULc\NUL" os-string Similar to  , returns the longest (possibly empty) prefix of elements satisfying the predicate. os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate. p is equivalent to  .  p . . os-stringO(n)  n xs returns the suffix of xs after the first n elements, or [] if n >  xs."Note: copies the entire byte array os-stringO(1)  n xs is equivalent to  ( xs - n) xs . Drops n! elements from end of bytestring./dropEnd 3 "a\NULb\NULc\NULd\NULe\NULf\NULg\NUL""a\NULb\NULc\NULd\NUL"/dropEnd 0 "a\NULb\NULc\NULd\NULe\NULf\NULg\NUL"%"a\NULb\NULc\NULd\NULe\NULf\NULg\NUL"dropEnd 4 "a\NULb\NULc\NUL""" os-string Similar to  , drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder."Note: copies the entire byte array  os-string Similar to  , drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. p is equivalent to  .  p . . os-string>Returns the longest (possibly empty) suffix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to  , returns the longest (possibly empty) prefix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to  , returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p). os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p).We have 0spanEnd (not . isSpace) "x y z" == ("x y ", "z")and spanEnd (not . isSpace) ps == let (x, y) = span (not . isSpace) (reverse ps) in (reverse y, reverse x) os-stringO(n)  n xs is equivalent to ( n xs,  n xs).Note: copies the substrings os-stringO(n) Break a  into pieces separated by the byte argument, consuming the delimiter. I.e. split 10 "a\nb\nd\ne" == ["a","b","d","e"] -- fromEnum '\n' == 10 split 97 "aXaXaXa" == ["","X","X","X",""] -- fromEnum 'a' == 97 split 120 "x" == ["",""] -- fromEnum 'x' == 120 split undefined "" == [] -- and not [""]and 9intercalate [c] . split c == id split == splitWith . (==)Note: copies the substrings os-stringO(n) Splits a  into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg. splitWith (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97 splitWith undefined "" == [] -- and not [""] os-string3Check whether one string is a substring of another. os-string, applied to a binary operator, a starting value (typically the left-identity of the operator), and a ShortByteString, reduces the ShortByteString using the binary operator, from left to right. os-string is like  , but strict in the accumulator. os-string, applied to a binary operator, a starting value (typically the right-identity of the operator), and a ShortByteString, reduces the ShortByteString using the binary operator, from right to left. os-string is like  , but strict in the accumulator. os-string is a variant of  that has no starting value argument, and thus must be applied to non-empty s. An exception will be thrown in the case of an empty ShortByteString. os-string is like , but strict in the accumulator. An exception will be thrown in the case of an empty ShortByteString. os-string is a variant of  that has no starting value argument, and thus must be applied to non-empty s An exception will be thrown in the case of an empty ShortByteString. os-string is a variant of $, but is strict in the accumulator. os-stringO(1) - index (subscript) operator, starting from 0.  os-stringO(1) & index, starting from 0, that returns  if: 0 <= n < length bs  os-stringO(1) & index, starting from 0, that returns  if: 0 <= n < length bs os-stringO(n)  is the  membership predicate. os-stringO(n) , applied to a predicate and a ByteString, returns a ByteString containing those characters that satisfy the predicate. os-stringO(n) The  function takes a predicate and a ByteString, and returns the first element in matching the predicate, or  if there is no such element. find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing os-stringO(n) The  function takes a predicate a ByteString and returns the pair of ByteStrings with elements which do and do not satisfy the predicate, respectively; i.e., 4partition p bs == (filter p xs, filter (not . p) xs) os-stringO(n) The ? function returns the index of the first element in the given * which is equal to the query element, or  if there is no such element. os-stringO(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order. os-stringcount returns the number of times its argument appears in the ShortByteString os-stringO(n) The " function takes a predicate and a  and returns the index of the first element in the ByteString satisfying the predicate. os-stringO(n) The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order.  os-string number of  os-stringnumber of Word16 os-string number of  os-string number of  os-string number of  os-stringnumber of Word16 os-stringString to search for os-stringString to search in os-string+Head and tail of string broken at substring os-string number of  os-string number of  os-string number of  os-string number of  os-string number of tuv xy z{|}~w349:WX[YZtuv xy z{|}~w349:WX[YZx5y5 Safe-InferredE os-stringCould not decode a byte sequence because it was invalid under the given encoding, or ran out of input in mid-decode. os-stringMimics the base encoding for filesystem operations. This should be total on all inputs (word16 byte arrays).*Note that this has a subtle difference to /: it doesn't care for the 0x0000< end marker and will as such produce different results. Use takeWhile (/= 'NUL')( on the input to recover this behavior. os-stringDecode with the given . os-stringEncode with the given . os-stringThis mimics the filepath decoder base uses on unix, with the small distinction that we're not truncating at NUL bytes (because we're not at the outer FFI layer). os-stringThis mimics the filepath dencoder base uses on unix, with the small distinction that we're not truncating at NUL bytes (because we're not at the outer FFI layer). os-stringThis mimics the filepath decoder base uses on windows, with the small distinction that we're not truncating at NUL bytes (because we're not at the outer FFI layer). os-stringThis mimics the filepath dencoder base uses on windows, with the small distinction that we're not truncating at NUL bytes (because we're not at the outer FFI layer). Safe-InferredFk Safe-Inferred;NJ os-string!Newtype representing a code unit.7On Windows, this is restricted to two-octet codepoints , on POSIX one-octet (). os-string=Newtype representing short operating system specific strings.Internally this is either  or 1, depending on the platform. Both use unpinned ShortByteString for efficiency.%The constructor is only exported via System.OsString.Internal.Types, since dealing with the internals isn't generally recommended, but supported in case you need to write platform specific code. os-string,Commonly used Posix string as uninterpreted char[] array. os-string5Commonly used windows string as wide character bytes. os-string'Just a short bidirectional synonym for  constructor. os-string'Just a short bidirectional synonym for  constructor. os-string'Just a short bidirectional synonym for  constructor. os-string'Just a short bidirectional synonym for  constructor. os-string#This is a type-level evidence that  is a newtype wrapper over  or  and  is a newtype wrapper over  or . If you pattern match on , GHC will know that relevant types are coercible to each other. This helps to avoid CPP in certain scenarios. os-stringDecodes as UCS-2. os-string&Prints the raw bytes without decoding. os-string"String-Concatenation" for  . This is not the same as (). os-string-Byte ordering of the internal representation. os-string-Byte equality of the internal representation. os-stringOn windows, decodes as UCS-2. On unix prints the raw bytes without decoding. os-string-Byte ordering of the internal representation. os-string-Byte equality of the internal representation. Safe-Inferred(8 os-string"Partial unicode friendly encoding.7This encodes as UTF8 (strictly), which is a good guess. Throws an  if encoding fails. If the input does not contain surrogate chars, you can use . os-string!Unsafe unicode friendly encoding.Like , except it crashes when the input contains surrogate chars. For sanitized input, this can be useful. os-string Encode a  with the specified encoding. os-stringThis mimics the behavior of the base library when doing filesystem operations, which uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck).Looking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then  may be feasible (make sure to deeply evaluate the result to catch exceptions). os-string"Partial unicode friendly decoding.This decodes as UTF8 (strictly), which is a good guess. Note that filenames on unix are encoding agnostic char arrays. Throws a  if decoding fails. os-string Decode a  with the specified encoding.9The String is forced into memory to catch all exceptions. os-stringThis mimics the behavior of the base library when doing filesystem operations, which uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck).Looking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then  may be feasible (make sure to deeply evaluate the result to catch exceptions). os-string/Constructs a platform string from a ByteString.This is a no-op. os-string QuasiQuote a . This accepts Unicode characters and encodes as UTF-8 on unix. os-string5Unpack a platform string to a list of platform words. os-string3Pack a list of platform words to a platform string.)Note that using this in conjunction with  to convert from [Char] to platform string is probably not what you want, because it will truncate unicode code points. os-stringTruncates to 1 octet. os-string-Converts back to a unicode codepoint (total). os-stringO(n) Append a byte to the end of a OsString os-stringO(n)  is analogous to (:) for lists. os-stringO(1) Extract the last element of a OsString, which must be finite and non-empty. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Extract the elements after the head of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Extract the  and  of a OsString, returning  if it is empty. os-stringO(1) Extract the first element of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Return all the elements of a OsString except the last one. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Extract the  and  of a OsString, returning  if it is empty. os-stringO(1) . The empty OsString. os-stringO(1) The length of a OsString. os-stringO(n)  f xs& is the OsString obtained by applying f to each element of xs. os-stringO(n)  xs% efficiently returns the elements of xs in reverse order. os-stringO(n) The  function takes a OsString and a list of OsStrings and concatenates the list after interspersing the first argument between each element of the list. os-string, applied to a binary operator, a starting value (typically the left-identity of the operator), and a OsString, reduces the OsString using the binary operator, from left to right. os-string is like  , but strict in the accumulator. os-string is a variant of  that has no starting value argument, and thus must be applied to non-empty OsStrings. An exception will be thrown in the case of an empty OsString. os-string is like , but strict in the accumulator. An exception will be thrown in the case of an empty OsString. os-string, applied to a binary operator, a starting value (typically the right-identity of the operator), and a OsString, reduces the OsString using the binary operator, from right to left. os-string is like  , but strict in the accumulator. os-string is a variant of  that has no starting value argument, and thus must be applied to non-empty OsStrings An exception will be thrown in the case of an empty OsString. os-string is a variant of $, but is strict in the accumulator. os-stringO(n) Applied to a predicate and a OsString, $ determines if all elements of the OsString satisfy the predicate. os-stringO(n) Applied to a predicate and a OsString, # determines if any element of the OsString satisfies the predicate. os-stringO(n)  n x is a OsString of length n with x2 the value of every element. The following holds: .replicate w c = unfoldr w (\u -> Just (u,u)) c os-stringO(n), where n# is the length of the result. The 0 function is analogous to the List 'unfoldr'.  builds a OsString from a seed value. The function takes the element and returns 2 if it is done producing the OsString or returns  (a,b), in which case, a& is the next byte in the string, and b* is the seed value for further production.=This function is not efficient/safe. It will build a list of [Word8]) and run the generator until it returns 7, otherwise recurse infinitely, then finally create a OsString./If you know the maximum length, consider using . Examples:  unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0 == pack [0, 1, 2, 3, 4, 5] os-stringO(n) Like ,  builds a OsString from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than 1 when the maximum length of the result is known.The following equation relates  and : ,fst (unfoldrN n f s) == take n (unfoldr f s) os-stringO(n)  n, applied to a OsString xs, returns the prefix of xs of length n, or xs itself if n >  xs. os-stringO(n)  n xs is equivalent to  ( xs - n) xs . Takes n! elements from end of bytestring.takeEnd 3 "abcdefg""efg"takeEnd 0 "abcdefg"""takeEnd 4 "abc""abc" os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate. p is equivalent to  .  p . . os-string Similar to  , returns the longest (possibly empty) prefix of elements satisfying the predicate. os-stringO(n)  n xs returns the suffix of xs after the first n elements, or  if n >  xs. os-stringO(n)  n xs is equivalent to  ( xs - n) xs . Drops n! elements from end of bytestring.dropEnd 3 "abcdefg""abcd"dropEnd 0 "abcdefg" "abcdefg"dropEnd 4 "abc""" os-string Similar to  , drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder. os-string Similar to  , drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. p is equivalent to  .  p . . os-string>Returns the longest (possibly empty) suffix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to , returns the longest (possibly empty) prefix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to , returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p). os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p).We have 0spanEnd (not . isSpace) "x y z" == ("x y ", "z")and spanEnd (not . isSpace) sbs == let (x, y) = span (not . isSpace) (reverse sbs) in (reverse y, reverse x) os-stringO(n)  n sbs is equivalent to ( n sbs,  n sbs). os-stringO(n) Break a OsString into pieces separated by the byte argument, consuming the delimiter. I.e. split 10 "a\nb\nd\ne" == ["a","b","d","e"] -- fromEnum '\n' == 10 split 97 "aXaXaXa" == ["","X","X","X",""] -- fromEnum 'a' == 97 split 120 "x" == ["",""] -- fromEnum 'x' == 120 split undefined "" == [] -- and not [""]and 9intercalate [c] . split c == id split == splitWith . (==) os-stringO(n) Splits a OsString into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg. splitWith (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97 splitWith undefined "" == [] -- and not [""] os-stringO(n) The * function takes two OsStrings and returns  the remainder of the second iff the first is its suffix, and otherwise . os-stringO(n) The * function takes two OsStrings and returns  the remainder of the second iff the first is its prefix, and otherwise . os-string3Check whether one string is a substring of another. os-stringO(n) The * function takes two OsStrings and returns  os-stringO(n) The * function takes two OsStrings and returns * iff the first is a suffix of the second.The following holds: 2isSuffixOf x y == reverse x `isPrefixOf` reverse y os-stringBreak a string on a substring, returning a pair of the part of the string prior to the match, and the rest of the string.!The following relationships hold: 0break (== c) l == breakSubstring (singleton c) l7For example, to tokenise a string, dropping delimiters: tokenise x y = h : if null t then [] else tokenise x (drop (length x) t) where (h,t) = breakSubstring x y,To skip to the first occurrence of a string: snd (breakSubstring x y)1To take the parts of a string before a delimiter: fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern. os-stringO(n)  is the OsString membership predicate. os-stringO(n) The  function takes a predicate and a OsString, and returns the first element in matching the predicate, or  if there is no such element. find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing os-stringO(n) , applied to a predicate and a OsString, returns a OsString containing those characters that satisfy the predicate. os-stringO(n) The  function takes a predicate a OsString and returns the pair of OsStrings with elements which do and do not satisfy the predicate, respectively; i.e., 6partition p bs == (filter p sbs, filter (not . p) sbs) os-stringO(1) OsString- index (subscript) operator, starting from 0. os-stringO(1) OsString& index, starting from 0, that returns  if: 0 <= n < length bs os-stringO(1) OsString& index, starting from 0, that returns  if: 0 <= n < length bs os-stringO(n) The ? function returns the index of the first element in the given OsString* which is equal to the query element, or  if there is no such element. os-stringO(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order. os-stringcount returns the number of times its argument appears in the OsString os-stringO(n) The " function takes a predicate and a OsString and returns the index of the first element in the OsString satisfying the predicate. os-stringO(n) The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order. Safe-Inferred ( os-string"Partial unicode friendly encoding.On windows this encodes as UTF16-LE (strictly), which is a pretty good guess. On unix this encodes as UTF8 (strictly), which is a good guess. Throws an  if encoding fails. If the input does not contain surrogate chars, you can use . os-string!Unsafe unicode friendly encoding.Like , except it crashes when the input contains surrogate chars. For sanitized input, this can be useful. os-string Encode an ' given the platform specific encodings. os-stringLike , except this mimics the behavior of the base library when doing filesystem operations, which is: on unix, uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck)on windows does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate rangeLooking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then unsafePerformIO may be feasible (make sure to deeply evaluate the result to catch exceptions). os-string"Partial unicode friendly decoding.On windows this decodes as UTF16-LE (strictly), which is a pretty good guess. On unix this decodes as UTF8 (strictly), which is a good guess. Note that filenames on unix are encoding agnostic char arrays. Throws a  if decoding fails. os-string Decode an  with the specified encoding.9The String is forced into memory to catch all exceptions. os-stringLike , except this mimics the behavior of the base library when doing filesystem operations, which is: on unix, uses shady PEP 383 style encoding (based on the current locale, but PEP 383 only works properly on UTF-8 encodings, so good luck)on windows does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate rangeLooking up the locale requires IO. If you're not worried about calls to setFileSystemEncoding, then unsafePerformIO may be feasible (make sure to deeply evaluate the result to catch exceptions). os-stringConstructs an OsString from a ByteString.On windows, this ensures valid UCS-2LE, on unix it is passed unchanged/unchecked.Throws 3 on invalid UCS-2LE on windows (although unlikely). os-stringQuasiQuote an . This accepts Unicode characters and encodes as UTF-8 on unix and UTF-16 on windows. If used as pattern, requires turning on the  ViewPatterns extension. os-string Unpack an  to a list of . os-stringPack a list of  to an )Note that using this in conjunction with  to convert from [Char] to  is probably not what you want, because it will truncate unicode code points. os-string2Truncates on unix to 1 and on Windows to 2 octets. os-string-Converts back to a unicode codepoint (total). os-stringO(n) Append a byte to the end of a  os-stringO(n)  is analogous to (:) for lists. os-stringO(1) Extract the last element of a OsString, which must be finite and non-empty. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Extract the elements after the head of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Extract the  and  of a OsString, returning  if it is empty. os-stringO(1) Extract the first element of a OsString, which must be non-empty. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Return all the elements of a  except the last one. An exception will be thrown in the case of an empty OsString.+This is a partial function, consider using  instead. os-stringO(n) Extract the  and  of a OsString, returning  if it is empty. os-stringO(1) Test whether a  is empty. os-stringO(1) The length of a . os-stringO(n)  f xs& is the OsString obtained by applying f to each element of xs. os-stringO(n)  xs% efficiently returns the elements of xs in reverse order. os-stringO(n) The  function takes a  and a list of s and concatenates the list after interspersing the first argument between each element of the list. os-string, applied to a binary operator, a starting value (typically the left-identity of the operator), and a OsString, reduces the OsString using the binary operator, from left to right. os-string is like  , but strict in the accumulator. os-string is a variant of  that has no starting value argument, and thus must be applied to non-empty s. An exception will be thrown in the case of an empty OsString. os-string is like , but strict in the accumulator. An exception will be thrown in the case of an empty OsString. os-string, applied to a binary operator, a starting value (typically the right-identity of the operator), and a OsString, reduces the OsString using the binary operator, from right to left. os-string is like  , but strict in the accumulator. os-string is a variant of  that has no starting value argument, and thus must be applied to non-empty s An exception will be thrown in the case of an empty OsString. os-string is a variant of $, but is strict in the accumulator. os-stringO(n) Applied to a predicate and a , $ determines if all elements of the  satisfy the predicate. os-stringO(n) Applied to a predicate and a , # determines if any element of the  satisfies the predicate. os-stringO(n)  n x is a OsString of length n with x2 the value of every element. The following holds: .replicate w c = unfoldr w (\u -> Just (u,u)) c os-stringO(n), where n# is the length of the result. The 0 function is analogous to the List 'unfoldr'.  builds a OsString from a seed value. The function takes the element and returns 2 if it is done producing the OsString or returns  (a,b), in which case, a& is the next byte in the string, and b* is the seed value for further production.=This function is not efficient/safe. It will build a list of [Word8]) and run the generator until it returns 7, otherwise recurse infinitely, then finally create a ./If you know the maximum length, consider using . Examples:  unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0 == pack [0, 1, 2, 3, 4, 5] os-stringO(n) Like ,  builds a OsString from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than 1 when the maximum length of the result is known.The following equation relates  and : ,fst (unfoldrN n f s) == take n (unfoldr f s) os-stringO(n)  n, applied to a OsString xs, returns the prefix of xs of length n, or xs itself if n >  xs. os-stringO(n)  n xs is equivalent to  ( xs - n) xs . Takes n! elements from end of bytestring.takeEnd 3 "abcdefg""efg"takeEnd 0 "abcdefg"""takeEnd 4 "abc""abc" os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate. p is equivalent to  .  p . . os-string Similar to , returns the longest (possibly empty) prefix of elements satisfying the predicate. os-stringO(n)  n xs returns the suffix of xs after the first n elements, or  if n >  xs. os-stringO(n)  n xs is equivalent to  ( xs - n) xs . Drops n! elements from end of bytestring.dropEnd 3 "abcdefg""abcd"dropEnd 0 "abcdefg" "abcdefg"dropEnd 4 "abc""" os-string Similar to , drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder. os-string Similar to  , drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. p is equivalent to  .  p . . os-string>Returns the longest (possibly empty) suffix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to , returns the longest (possibly empty) prefix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to , returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p). os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p).We have 0spanEnd (not . isSpace) "x y z" == ("x y ", "z")and spanEnd (not . isSpace) sbs == let (x, y) = span (not . isSpace) (reverse sbs) in (reverse y, reverse x) os-stringO(n)  n sbs is equivalent to ( n sbs,  n sbs). os-stringO(n) Break a  into pieces separated by the byte argument, consuming the delimiter. I.e. split 10 "a\nb\nd\ne" == ["a","b","d","e"] -- fromEnum '\n' == 10 split 97 "aXaXaXa" == ["","X","X","X",""] -- fromEnum 'a' == 97 split 120 "x" == ["",""] -- fromEnum 'x' == 120 split undefined "" == [] -- and not [""]and 9intercalate [c] . split c == id split == splitWith . (==) os-stringO(n) Splits a  into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg. splitWith (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97 splitWith undefined "" == [] -- and not [""] os-stringO(n) The * function takes two OsStrings and returns  the remainder of the second iff the first is its suffix, and otherwise . os-stringO(n) The * function takes two OsStrings and returns  the remainder of the second iff the first is its prefix, and otherwise . os-string3Check whether one string is a substring of another. os-stringO(n) The * function takes two OsStrings and returns  os-stringO(n) The * function takes two OsStrings and returns * iff the first is a suffix of the second.The following holds: 2isSuffixOf x y == reverse x `isPrefixOf` reverse y os-stringBreak a string on a substring, returning a pair of the part of the string prior to the match, and the rest of the string.!The following relationships hold: 0break (== c) l == breakSubstring (singleton c) l7For example, to tokenise a string, dropping delimiters: tokenise x y = h : if null t then [] else tokenise x (drop (length x) t) where (h,t) = breakSubstring x y,To skip to the first occurrence of a string: snd (breakSubstring x y)1To take the parts of a string before a delimiter: fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern. os-stringO(n)  is the  membership predicate. os-stringO(n) The  function takes a predicate and a OsString, and returns the first element in matching the predicate, or  if there is no such element. find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing os-stringO(n) , applied to a predicate and a OsString, returns a OsString containing those characters that satisfy the predicate. os-stringO(n) The  function takes a predicate a OsString and returns the pair of OsStrings with elements which do and do not satisfy the predicate, respectively; i.e., 6partition p bs == (filter p sbs, filter (not . p) sbs) os-stringO(1) - index (subscript) operator, starting from 0. os-stringO(1) & index, starting from 0, that returns  if: 0 <= n < length bs os-stringO(1) & index, starting from 0, that returns  if: 0 <= n < length bs os-stringO(n) The ? function returns the index of the first element in the given * which is equal to the query element, or  if there is no such element. os-stringO(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order. os-stringcount returns the number of times its argument appears in the OsString os-stringO(n) The " function takes a predicate and a  and returns the index of the first element in the OsString satisfying the predicate. os-stringO(n) The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order. os-stringunix text encoding os-stringwindows text encoding os-stringunix text encoding os-stringwindows text encoding 2021 Julian OspaldMIT"Julian Ospald  experimentalportable Safe-InferredÉ Safe-Inferred(3 os-string"Partial unicode friendly encoding.This encodes as UTF16-LE (strictly), which is a pretty good guess. Throws an  if encoding fails. If the input does not contain surrogate chars, you can use unsafeEncodeUtf. os-string!Unsafe unicode friendly encoding.Like , except it crashes when the input contains surrogate chars. For sanitized input, this can be useful. os-string Encode a  with the specified encoding. os-stringThis mimics the behavior of the base library when doing filesystem operations, which does permissive UTF-16 encoding, where coding errors generate Chars in the surrogate range.The reason this is in IO is because it unifies with the Posix counterpart, which does require IO. This is safe to /unsafeDupablePerformIO. os-string"Partial unicode friendly decoding. Just (u,u)) c os-stringO(n), where n# is the length of the result. The 0 function is analogous to the List 'unfoldr'.  builds a OsString from a seed value. The function takes the element and returns 2 if it is done producing the OsString or returns  (a,b), in which case, a& is the next byte in the string, and b* is the seed value for further production.=This function is not efficient/safe. It will build a list of [Word8]) and run the generator until it returns 7, otherwise recurse infinitely, then finally create a OsString./If you know the maximum length, consider using . Examples:  unfoldr (\x -> if x <= 5 then Just (x, x + 1) else Nothing) 0 == pack [0, 1, 2, 3, 4, 5] os-stringO(n) Like ,  builds a OsString from a seed value. However, the length of the result is limited by the first argument to (. This function is more efficient than 1 when the maximum length of the result is known.The following equation relates  and : ,fst (unfoldrN n f s) == take n (unfoldr f s) os-stringO(n)  n, applied to a OsString xs, returns the prefix of xs of length n, or xs itself if n >  xs. os-stringO(n)  n xs is equivalent to  ( xs - n) xs . Takes n! elements from end of bytestring.takeEnd 3 "abcdefg""efg"takeEnd 0 "abcdefg"""takeEnd 4 "abc""abc" os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate. p is equivalent to  .  p . . os-string Similar to  , returns the longest (possibly empty) prefix of elements satisfying the predicate. os-stringO(n)  n xs returns the suffix of xs after the first n elements, or  if n >  xs. os-stringO(n)  n xs is equivalent to  ( xs - n) xs . Drops n! elements from end of bytestring.dropEnd 3 "abcdefg""abcd"dropEnd 0 "abcdefg" "abcdefg"dropEnd 4 "abc""" os-string Similar to  , drops the longest (possibly empty) prefix of elements satisfying the predicate and returns the remainder. os-string Similar to  , drops the longest (possibly empty) suffix of elements satisfying the predicate and returns the remainder. p is equivalent to  .  p . . os-string>Returns the longest (possibly empty) suffix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to , returns the longest (possibly empty) prefix of elements which do not8 satisfy the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( (not . p) &&&  (not . p)). os-string Similar to , returns the longest (possibly empty) prefix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p). os-stringReturns the longest (possibly empty) suffix of elements satisfying the predicate and the remainder of the string. p is equivalent to  (not . p) and to ( p &&&  p).We have 0spanEnd (not . isSpace) "x y z" == ("x y ", "z")and spanEnd (not . isSpace) sbs == let (x, y) = span (not . isSpace) (reverse sbs) in (reverse y, reverse x) os-stringO(n)  n sbs is equivalent to ( n sbs,  n sbs). os-stringO(n) Break a OsString into pieces separated by the byte argument, consuming the delimiter. I.e. split 10 "a\nb\nd\ne" == ["a","b","d","e"] -- fromEnum '\n' == 10 split 97 "aXaXaXa" == ["","X","X","X",""] -- fromEnum 'a' == 97 split 120 "x" == ["",""] -- fromEnum 'x' == 120 split undefined "" == [] -- and not [""]and 9intercalate [c] . split c == id split == splitWith . (==) os-stringO(n) Splits a OsString into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg. splitWith (==97) "aabbaca" == ["","","bb","c",""] -- fromEnum 'a' == 97 splitWith undefined "" == [] -- and not [""] os-stringO(n) The * function takes two OsStrings and returns  the remainder of the second iff the first is its suffix, and otherwise . os-stringO(n) The * function takes two OsStrings and returns  the remainder of the second iff the first is its prefix, and otherwise . os-string3Check whether one string is a substring of another. os-stringO(n) The * function takes two OsStrings and returns  os-stringO(n) The * function takes two OsStrings and returns * iff the first is a suffix of the second.The following holds: 2isSuffixOf x y == reverse x `isPrefixOf` reverse y os-stringBreak a string on a substring, returning a pair of the part of the string prior to the match, and the rest of the string.!The following relationships hold: 0break (== c) l == breakSubstring (singleton c) l7For example, to tokenise a string, dropping delimiters: tokenise x y = h : if null t then [] else tokenise x (drop (length x) t) where (h,t) = breakSubstring x y,To skip to the first occurrence of a string: snd (breakSubstring x y)1To take the parts of a string before a delimiter: fst (breakSubstring x y)Note that calling `breakSubstring x` does some preprocessing work, so you should avoid unnecessarily duplicating breakSubstring calls with the same pattern. os-stringO(n)  is the OsString membership predicate. os-stringO(n) The  function takes a predicate and a OsString, and returns the first element in matching the predicate, or  if there is no such element. find f p = case findIndex f p of Just n -> Just (p ! n) ; _ -> Nothing os-stringO(n) , applied to a predicate and a OsString, returns a OsString containing those characters that satisfy the predicate. os-stringO(n) The  function takes a predicate a OsString and returns the pair of OsStrings with elements which do and do not satisfy the predicate, respectively; i.e., 6partition p bs == (filter p sbs, filter (not . p) sbs) os-stringO(1) OsString- index (subscript) operator, starting from 0. os-stringO(1) OsString& index, starting from 0, that returns  if: 0 <= n < length bs os-stringO(1) OsString& index, starting from 0, that returns  if: 0 <= n < length bs os-stringO(n) The ? function returns the index of the first element in the given OsString* which is equal to the query element, or  if there is no such element. os-stringO(n) The  function extends , by returning the indices of all elements equal to the query element, in ascending order. os-stringcount returns the number of times its argument appears in the OsString os-stringO(n) The " function takes a predicate and a OsString and returns the index of the first element in the OsString satisfying the predicate. os-stringO(n) The  function extends , by returning the indices of all elements satisfying the predicate, in ascending order. !"#$%&'()*+,-./0123456789 :;<=  >?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ !$%&'()*+,-78EFG9: ;<=  >?@ABHK/0123456LMNOPQRST! $%&'()*+,-./034125678#EFG9:; <=  >?@ABCDHIJKLNMOPQRST! $%&'()*+,-./034125678#EFG9:; <=  >?@ABCDHIJKLNMOPQRST! $%&'()*+,-./034125678#EFG9:; <=  >?@ABCDHIJKLNMOPQRST  os-string-2.0.2-inplace%System.OsString.Data.ByteString.Short.System.OsString.Data.ByteString.Short.Internal,System.OsString.Data.ByteString.Short.Word16!System.OsString.Encoding.InternalSystem.OsString.Internal.TypesSystem.OsString.PosixSystem.OsString.InternalSystem.OsString.Windows os-stringP takeWhile dropWhile dropWhileEndbreakspanSystem.OsString.EncodingPreludeSystem.OsStringbytestring-0.11.5.3Data.ByteString.Short.InternalShortByteStringSBSemptylengthnullindex indexMaybe!?toShort fromShort singletonpackunpackappendconcatsnocconslasttailunconsheadinitunsnocmapreverse intercalatefoldlfoldl'foldrfoldr'foldl1foldl1'foldr1foldr1'allanytaketakeEnd takeWhileEnddropdropEndbreakEndspanEndsplitAtsplit splitWith stripSuffix stripPrefix replicateunfoldrunfoldrN isInfixOf isPrefixOf isSuffixOfbreakSubstringelemfilterfind partition elemIndex elemIndicescount findIndex findIndices packCStringpackCStringLen useAsCStringuseAsCStringLenMBAMBA#BABA#_nulisSpace word16ToCharcreateasBAnewPinnedByteArray newByteArray copyByteArrayunsafeFreezeByteArraycopyAddrToByteArray packCWStringpackCWStringLen useAsCWStringuseAsCWStringLen newCWString moduleErrorIOmoduleErrorMsg packWord16 packLenWord16 unpackWord16 packWord16RevpackLenWord16RevwriteWord16ArrayindexWord8ArrayindexWord16Array word16ToLE# word16FromLE# setByteArraycopyMutableByteArray createAndTrimcreateAndTrim'createAndTrim''findIndexOrLengthfindFromEndUntil assertEven errorEmptySBS moduleErrorcompareByteArraysOffuncons2 numWord16EncodingException EncodingErrorucs2lemkUcs2le ucs2le_DF ucs2le_EF ucs2le_decode ucs2le_encode utf16le_b mkUTF16le_b utf16le_b_DF utf16le_b_EFutf16le_b_decodeutf16le_b_encodecWcharsToChars_UCS2cWcharsToCharscharsToCWcharswithWindowsStringpeekWindowsStringwithPosixStringpeekPosixString decodeWithTE encodeWithTEdecodeWithBasePosixencodeWithBasePosixdecodeWithBaseWindowsencodeWithBaseWindowsshowEncodingExceptionwNUL$fNFDataEncodingException$fExceptionEncodingException$fShowEncodingException$fEqEncodingExceptionOsChar getOsCharOsString getOsString PlatformChar PosixChar getPosixChar WindowsChargetWindowsCharPlatformString PosixStringgetPosixString WindowsStringgetWindowsStringPWunPWWWunWWPSunPSWSunWScoercionToPlatformTypes$fLiftBoxedRepWindowsString$fShowWindowsString$fLiftBoxedRepPosixString$fShowPosixString$fShowWindowsChar$fShowPosixChar$fLiftBoxedRepOsString$fSemigroupOsString$fMonoidOsString $fOrdOsString $fEqOsString$fShowOsString $fOrdOsChar $fEqOsChar $fShowOsChar$fGenericOsChar$fNFDataOsChar$fGenericOsString$fNFDataOsString $fEqPosixChar$fOrdPosixChar$fGenericPosixChar$fNFDataPosixChar$fEqWindowsChar$fOrdWindowsChar$fGenericWindowsChar$fNFDataWindowsChar$fEqPosixString$fOrdPosixString$fSemigroupPosixString$fMonoidPosixString$fGenericPosixString$fNFDataPosixString$fEqWindowsString$fOrdWindowsString$fSemigroupWindowsString$fMonoidWindowsString$fGenericWindowsString$fNFDataWindowsString encodeUtfunsafeEncodeUtf encodeWithencodeFS decodeUtf decodeWithdecodeFS fromBytespstrunsafeFromChartoCharosstrbaseGHC.WordWord16Word8 GHC.MaybeNothingJust unsafeIndexGHC.IO.Encoding.Types TextEncodingGHC.BaseString GHC.IO.UnsafeunsafePerformIOghc-prim GHC.TypesTrueGHC.List