Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
utf8-string
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Glasgow Haskell Compiler
Packages
utf8-string
Commits
c9c30814
Commit
c9c30814
authored
10 years ago
by
glguy
Browse files
Options
Downloads
Patches
Plain Diff
Whitespace and tabs
parent
31969fde
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Codec/Binary/UTF8/String.hs
+10
-10
10 additions, 10 deletions
Codec/Binary/UTF8/String.hs
with
10 additions
and
10 deletions
Codec/Binary/UTF8/String.hs
+
10
−
10
View file @
c9c30814
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
-- Module : Codec.Binary.UTF8.String
-- Module : Codec.Binary.UTF8.String
-- Copyright : (c) Eric Mertens 2007
-- Copyright : (c) Eric Mertens 2007
-- License : BSD3-style (see LICENSE)
-- License : BSD3-style (see LICENSE)
--
--
-- Maintainer: emertens@galois.com
-- Maintainer: emertens@galois.com
-- Stability : experimental
-- Stability : experimental
-- Portability : portable
-- Portability : portable
...
@@ -21,7 +21,7 @@ module Codec.Binary.UTF8.String (
...
@@ -21,7 +21,7 @@ module Codec.Binary.UTF8.String (
,
encodeString
,
encodeString
,
decodeString
,
decodeString
,
encodeChar
,
encodeChar
,
isUTF8Encoded
,
isUTF8Encoded
,
utf8Encode
,
utf8Encode
)
where
)
where
...
@@ -122,7 +122,7 @@ utf8Encode str
...
@@ -122,7 +122,7 @@ utf8Encode str
-- | @isUTF8Encoded str@ tries to recognize input string as being in UTF-8 form.
-- | @isUTF8Encoded str@ tries to recognize input string as being in UTF-8 form.
isUTF8Encoded
::
String
->
Bool
isUTF8Encoded
::
String
->
Bool
isUTF8Encoded
[]
=
True
isUTF8Encoded
[]
=
True
isUTF8Encoded
(
x
:
xs
)
=
isUTF8Encoded
(
x
:
xs
)
=
case
ox
of
case
ox
of
_
|
ox
<
0x80
->
isUTF8Encoded
xs
_
|
ox
<
0x80
->
isUTF8Encoded
xs
|
ox
>
0xff
->
False
|
ox
>
0xff
->
False
...
@@ -135,14 +135,14 @@ isUTF8Encoded (x:xs) =
...
@@ -135,14 +135,14 @@ isUTF8Encoded (x:xs) =
|
otherwise
->
False
|
otherwise
->
False
where
where
ox
=
toW32
x
ox
=
toW32
x
toW32
::
Char
->
Word32
toW32
::
Char
->
Word32
toW32
ch
=
fromIntegral
(
fromEnum
ch
)
toW32
ch
=
fromIntegral
(
fromEnum
ch
)
check1
=
check1
=
case
xs
of
case
xs
of
[]
->
False
[]
->
False
c1
:
ds
c1
:
ds
|
oc
.&.
0xc0
/=
0x80
||
d
<
0x000080
->
False
|
oc
.&.
0xc0
/=
0x80
||
d
<
0x000080
->
False
|
otherwise
->
isUTF8Encoded
ds
|
otherwise
->
isUTF8Encoded
ds
where
where
...
@@ -153,15 +153,15 @@ isUTF8Encoded (x:xs) =
...
@@ -153,15 +153,15 @@ isUTF8Encoded (x:xs) =
check_byte
i
mask
overlong
=
aux
i
xs
(
ox
.&.
mask
)
check_byte
i
mask
overlong
=
aux
i
xs
(
ox
.&.
mask
)
where
where
aux
0
rs
acc
aux
0
rs
acc
|
overlong
<=
acc
&&
|
overlong
<=
acc
&&
acc
<=
0x10ffff
&&
acc
<=
0x10ffff
&&
(
acc
<
0xd800
||
0xdfff
<
acc
)
&&
(
acc
<
0xd800
||
0xdfff
<
acc
)
&&
(
acc
<
0xfffe
||
0xffff
<
acc
)
=
isUTF8Encoded
rs
(
acc
<
0xfffe
||
0xffff
<
acc
)
=
isUTF8Encoded
rs
|
otherwise
=
False
|
otherwise
=
False
aux
n
(
r
:
rs
)
acc
aux
n
(
r
:
rs
)
acc
|
toW32
r
.&.
0xc0
==
0x80
=
|
toW32
r
.&.
0xc0
==
0x80
=
aux
(
n
-
1
)
rs
(
acc
`
shiftL
`
6
.|.
(
toW32
r
.&.
0x3f
))
aux
(
n
-
1
)
rs
(
acc
`
shiftL
`
6
.|.
(
toW32
r
.&.
0x3f
))
aux
_
_
_
=
False
aux
_
_
_
=
False
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment