Skip to content

Commit

Permalink
Format code and factor out method
Browse files Browse the repository at this point in the history
  • Loading branch information
marschall committed Sep 12, 2022
1 parent c547682 commit fa91963
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parsing-internal
createCodePointFromSurrogatesHigh: aHighInteger low: aLowInteger
^ 16r10000 + ((aHighInteger - 16rD800 bitShift: 10) bitOr: (aLowInteger - 16rDC00))
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ parsing-internal
parseCharacterHex
| value |
value := self parseCharacterHexRaw.
(self isHighSurrogate: value) ifTrue: [
| lowSurrogate |
self expectChar: $\.
self expectChar: $u.
lowSurrogate := self parseCharacterHexRaw.
(self isLowSurrogate: lowSurrogate) ifFalse: [
^ self error: 'low surrogate expected' ].
value := 16r10000 + ((value - 16rD800 bitShift: 10) bitOr: (lowSurrogate - 16rDC00)) ].
(self isLowSurrogate: value) ifTrue:[ self error: 'high surrogate expected' ].
(self isHighSurrogate: value)
ifTrue: [
| lowSurrogate |
self expectChar: $\.
self expectChar: $u.
lowSurrogate := self parseCharacterHexRaw.
(self isLowSurrogate: lowSurrogate) ifFalse: [
^ self error: 'low surrogate expected' ].
value := self createCodePointFromSurrogatesHigh: value low: lowSurrogate ]
ifFalse: [
(self isLowSurrogate: value)
ifTrue: [ self error: 'unexpected low surrogate' ] ].
^ Character codePoint: value

0 comments on commit fa91963

Please sign in to comment.