Skip to content

Commit 2cca32c

Browse files
authored
chore: use UTF8 instead of Utf8 in identifiers (#10636)
This PR renames `String.getUtf8Byte` to `String.getUTF8Byte` in order to adhere to the standard library naming convention.
1 parent 784a063 commit 2cca32c

File tree

14 files changed

+195
-206
lines changed

14 files changed

+195
-206
lines changed

src/Init/Data/String/Basic.lean

Lines changed: 125 additions & 130 deletions
Large diffs are not rendered by default.

src/Init/Data/String/Decode.lean

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ end ByteArray.utf8DecodeChar?
982982

983983
open ByteArray.utf8DecodeChar?
984984

985-
/- # `utf8DecodeChar?` and `validateUtf8At` -/
985+
/- # `utf8DecodeChar?` and `validateUTF8At` -/
986986

987987
@[inline, expose]
988988
public def ByteArray.utf8DecodeChar? (bytes : ByteArray) (i : Nat) : Option Char :=
@@ -1006,7 +1006,7 @@ public def ByteArray.utf8DecodeChar? (bytes : ByteArray) (i : Nat) : Option Char
10061006
else none
10071007

10081008
@[inline, expose]
1009-
public def ByteArray.validateUtf8At (bytes : ByteArray) (i : Nat) : Bool :=
1009+
public def ByteArray.validateUTF8At (bytes : ByteArray) (i : Nat) : Bool :=
10101010
if h₀ : i < bytes.size then
10111011
match h : parseFirstByte bytes[i] with
10121012
| .invalid => false
@@ -1212,9 +1212,9 @@ public theorem String.toByteArray_utf8EncodeChar_of_utf8DecodeChar?_eq_some {b :
12121212
rw [← assemble₄_eq_some_iff_utf8EncodeChar_eq]
12131213
exact ⟨this, h⟩
12141214

1215-
public theorem ByteArray.validateUtf8At_eq_isSome_utf8DecodeChar? {b : ByteArray} {i : Nat} :
1216-
b.validateUtf8At i = (b.utf8DecodeChar? i).isSome := by
1217-
simp only [validateUtf8At, utf8DecodeChar?]
1215+
public theorem ByteArray.validateUTF8At_eq_isSome_utf8DecodeChar? {b : ByteArray} {i : Nat} :
1216+
b.validateUTF8At i = (b.utf8DecodeChar? i).isSome := by
1217+
simp only [validateUTF8At, utf8DecodeChar?]
12181218
split
12191219
· split <;> (try split) <;> simp [verify₁_eq_isSome_assemble₁, verify₂_eq_isSome_assemble₂,
12201220
verify₃_eq_isSome_assemble₃, verify₄_eq_isSome_assemble₄]
@@ -1285,9 +1285,9 @@ public theorem ByteArray.lt_size_of_isSome_utf8DecodeChar? {b : ByteArray} {i :
12851285
have := c.utf8Size_pos
12861286
omega
12871287

1288-
public theorem ByteArray.lt_size_of_validateUtf8At {b : ByteArray} {i : Nat} :
1289-
validateUtf8At b i = true → i < b.size :=
1290-
validateUtf8At_eq_isSome_utf8DecodeChar? ▸ lt_size_of_isSome_utf8DecodeChar?
1288+
public theorem ByteArray.lt_size_of_validateUTF8At {b : ByteArray} {i : Nat} :
1289+
validateUTF8At b i = true → i < b.size :=
1290+
validateUTF8At_eq_isSome_utf8DecodeChar? ▸ lt_size_of_isSome_utf8DecodeChar?
12911291

12921292
public theorem ByteArray.utf8DecodeChar?_append_eq_some {b : ByteArray} {i : Nat} {c : Char} (h : utf8DecodeChar? b i = some c)
12931293
(b' : ByteArray) : utf8DecodeChar? (b ++ b') i = some c := by
@@ -1366,7 +1366,7 @@ public theorem List.utf8DecodeChar_utf8Encode_cons {l : List Char} {c : Char} {h
13661366
ByteArray.utf8DecodeChar (c::l).utf8Encode 0 h = c := by
13671367
simp [ByteArray.utf8DecodeChar]
13681368

1369-
/-! # `UInt8.IsUtf8FirstByte` -/
1369+
/-! # `UInt8.IsUTF8FirstByte` -/
13701370

13711371
namespace UInt8
13721372

@@ -1375,27 +1375,27 @@ Predicate for whether a byte can appear as the first byte of the UTF-8 encoding
13751375
scalar value.
13761376
-/
13771377
@[expose]
1378-
public def IsUtf8FirstByte (c : UInt8) : Prop :=
1378+
public def IsUTF8FirstByte (c : UInt8) : Prop :=
13791379
c &&& 0x80 = 0 ∨ c &&& 0xe0 = 0xc0 ∨ c &&& 0xf0 = 0xe0 ∨ c &&& 0xf8 = 0xf0
13801380

1381-
public instance {c : UInt8} : Decidable c.IsUtf8FirstByte :=
1381+
public instance {c : UInt8} : Decidable c.IsUTF8FirstByte :=
13821382
inferInstanceAs <| Decidable (c &&& 0x80 = 0 ∨ c &&& 0xe0 = 0xc0 ∨ c &&& 0xf0 = 0xe0 ∨ c &&& 0xf8 = 0xf0)
13831383

1384-
theorem isUtf8FirstByte_iff_parseFirstByte_ne_invalid {c : UInt8} :
1385-
c.IsUtf8FirstByte ↔ parseFirstByte c ≠ FirstByte.invalid := by
1386-
fun_cases parseFirstByte with simp_all [IsUtf8FirstByte]
1384+
theorem isUTF8FirstByte_iff_parseFirstByte_ne_invalid {c : UInt8} :
1385+
c.IsUTF8FirstByte ↔ parseFirstByte c ≠ FirstByte.invalid := by
1386+
fun_cases parseFirstByte with simp_all [IsUTF8FirstByte]
13871387

13881388
@[simp]
1389-
public theorem isUtf8FirstByte_getElem_utf8EncodeChar {c : Char} {i : Nat} {hi : i < (String.utf8EncodeChar c).length} :
1390-
(String.utf8EncodeChar c)[i].IsUtf8FirstByte ↔ i = 0 := by
1389+
public theorem isUTF8FirstByte_getElem_utf8EncodeChar {c : Char} {i : Nat} {hi : i < (String.utf8EncodeChar c).length} :
1390+
(String.utf8EncodeChar c)[i].IsUTF8FirstByte ↔ i = 0 := by
13911391
obtain (rfl|hi₀) := Nat.eq_zero_or_pos i
1392-
· simp only [isUtf8FirstByte_iff_parseFirstByte_ne_invalid, iff_true]
1392+
· simp only [isUTF8FirstByte_iff_parseFirstByte_ne_invalid, iff_true]
13931393
match h : c.utf8Size, c.utf8Size_pos, c.utf8Size_le_four with
13941394
| 1, _, _ => simp [parseFirstByte_utf8EncodeChar_eq_done h]
13951395
| 2, _, _ => simp [parseFirstByte_utf8EncodeChar_eq_oneMore h]
13961396
| 3, _, _ => simp [parseFirstByte_utf8EncodeChar_eq_twoMore h]
13971397
| 4, _, _ => simp [parseFirstByte_utf8EncodeChar_eq_threeMore h]
1398-
· simp only [isUtf8FirstByte_iff_parseFirstByte_ne_invalid, ne_eq, Nat.ne_of_lt' hi₀, iff_false,
1398+
· simp only [isUTF8FirstByte_iff_parseFirstByte_ne_invalid, ne_eq, Nat.ne_of_lt' hi₀, iff_false,
13991399
Classical.not_not]
14001400
apply parseFirstByte_eq_invalid_of_isInvalidContinuationByte_eq_false
14011401
simp only [String.length_utf8EncodeChar] at hi
@@ -1408,12 +1408,12 @@ public theorem isUtf8FirstByte_getElem_utf8EncodeChar {c : Char} {i : Nat} {hi :
14081408
| 4, _, _, 2, _, _ => simp [isInvalidContinuationByte_getElem_utf8EncodeChar_two_of_utf8Size_eq_four h]
14091409
| 4, _, _, 3, _, _ => simp [isInvalidContinuationByte_getElem_utf8EncodeChar_three_of_utf8Size_eq_four h]
14101410

1411-
public theorem isUtf8FirstByte_getElem_zero_utf8EncodeChar {c : Char} :
1412-
((String.utf8EncodeChar c)[0]'(by simp [c.utf8Size_pos])).IsUtf8FirstByte := by
1411+
public theorem isUTF8FirstByte_getElem_zero_utf8EncodeChar {c : Char} :
1412+
((String.utf8EncodeChar c)[0]'(by simp [c.utf8Size_pos])).IsUTF8FirstByte := by
14131413
simp
14141414

14151415
@[expose]
1416-
public def utf8ByteSize (c : UInt8) (_h : c.IsUtf8FirstByte) : String.Pos.Raw :=
1416+
public def utf8ByteSize (c : UInt8) (_h : c.IsUTF8FirstByte) : String.Pos.Raw :=
14171417
if c &&& 0x80 = 0 then
14181418
1
14191419
else if c &&& 0xe0 = 0xc0 then
@@ -1430,7 +1430,7 @@ def _root_.ByteArray.utf8DecodeChar?.FirstByte.utf8ByteSize : FirstByte → Stri
14301430
| .twoMore => ⟨3
14311431
| .threeMore => ⟨4
14321432

1433-
theorem utf8ByteSize_eq_utf8ByteSize_parseFirstByte {c : UInt8} {h : c.IsUtf8FirstByte} :
1433+
theorem utf8ByteSize_eq_utf8ByteSize_parseFirstByte {c : UInt8} {h : c.IsUTF8FirstByte} :
14341434
c.utf8ByteSize h = (parseFirstByte c).utf8ByteSize := by
14351435
simp only [utf8ByteSize, FirstByte.utf8ByteSize, parseFirstByte, beq_iff_eq]
14361436
split
@@ -1447,28 +1447,28 @@ theorem utf8ByteSize_eq_utf8ByteSize_parseFirstByte {c : UInt8} {h : c.IsUtf8Fir
14471447

14481448
end UInt8
14491449

1450-
public theorem ByteArray.isUtf8FirstByte_getElem_zero_utf8EncodeChar_append {c : Char} {b : ByteArray} :
1451-
(((String.utf8EncodeChar c).toByteArray ++ b)[0]'(by simp; have := c.utf8Size_pos; omega)).IsUtf8FirstByte := by
1450+
public theorem ByteArray.isUTF8FirstByte_getElem_zero_utf8EncodeChar_append {c : Char} {b : ByteArray} :
1451+
(((String.utf8EncodeChar c).toByteArray ++ b)[0]'(by simp; have := c.utf8Size_pos; omega)).IsUTF8FirstByte := by
14521452
rw [ByteArray.getElem_append_left (by simp [c.utf8Size_pos]),
1453-
List.getElem_toByteArray, UInt8.isUtf8FirstByte_getElem_utf8EncodeChar]
1453+
List.getElem_toByteArray, UInt8.isUTF8FirstByte_getElem_utf8EncodeChar]
14541454

1455-
public theorem ByteArray.isUtf8FirstByte_of_isSome_utf8DecodeChar? {b : ByteArray} {i : Nat}
1456-
(h : (utf8DecodeChar? b i).isSome) : (b[i]'(lt_size_of_isSome_utf8DecodeChar? h)).IsUtf8FirstByte := by
1455+
public theorem ByteArray.isUTF8FirstByte_of_isSome_utf8DecodeChar? {b : ByteArray} {i : Nat}
1456+
(h : (utf8DecodeChar? b i).isSome) : (b[i]'(lt_size_of_isSome_utf8DecodeChar? h)).IsUTF8FirstByte := by
14571457
rw [utf8DecodeChar?_eq_utf8DecodeChar?_extract] at h
1458-
suffices ((b.extract i b.size)[0]'(lt_size_of_isSome_utf8DecodeChar? h)).IsUtf8FirstByte by
1458+
suffices ((b.extract i b.size)[0]'(lt_size_of_isSome_utf8DecodeChar? h)).IsUTF8FirstByte by
14591459
simpa [ByteArray.getElem_extract, Nat.add_zero] using this
14601460
obtain ⟨c, hc⟩ := Option.isSome_iff_exists.1 h
14611461
conv => congr; congr; rw [eq_of_utf8DecodeChar?_eq_some hc]
1462-
exact isUtf8FirstByte_getElem_zero_utf8EncodeChar_append
1462+
exact isUTF8FirstByte_getElem_zero_utf8EncodeChar_append
14631463

1464-
public theorem ByteArray.isUtf8FirstByte_of_validateUtf8At {b : ByteArray} {i : Nat} :
1465-
(h : validateUtf8At b i = true) → (b[i]'(lt_size_of_validateUtf8At h)).IsUtf8FirstByte := by
1466-
simp only [validateUtf8At_eq_isSome_utf8DecodeChar?]
1467-
exact isUtf8FirstByte_of_isSome_utf8DecodeChar?
1464+
public theorem ByteArray.isUTF8FirstByte_of_validateUTF8At {b : ByteArray} {i : Nat} :
1465+
(h : validateUTF8At b i = true) → (b[i]'(lt_size_of_validateUTF8At h)).IsUTF8FirstByte := by
1466+
simp only [validateUTF8At_eq_isSome_utf8DecodeChar?]
1467+
exact isUTF8FirstByte_of_isSome_utf8DecodeChar?
14681468

14691469
theorem Char.byteIdx_utf8ByteSize_getElem_utf8EncodeChar {c : Char} :
14701470
(((String.utf8EncodeChar c)[0]'(by simp [c.utf8Size_pos])).utf8ByteSize
1471-
UInt8.isUtf8FirstByte_getElem_zero_utf8EncodeChar).byteIdx = c.utf8Size := by
1471+
UInt8.isUTF8FirstByte_getElem_zero_utf8EncodeChar).byteIdx = c.utf8Size := by
14721472
rw [UInt8.utf8ByteSize_eq_utf8ByteSize_parseFirstByte]
14731473
obtain (hc|hc|hc|hc) := c.utf8Size_eq
14741474
· rw [parseFirstByte_utf8EncodeChar_eq_done hc, FirstByte.utf8ByteSize, hc]
@@ -1478,7 +1478,7 @@ theorem Char.byteIdx_utf8ByteSize_getElem_utf8EncodeChar {c : Char} :
14781478

14791479
public theorem ByteArray.utf8Size_utf8DecodeChar {b : ByteArray} {i} {h} :
14801480
(utf8DecodeChar b i h).utf8Size =
1481-
((b[i]'(lt_size_of_isSome_utf8DecodeChar? h)).utf8ByteSize (isUtf8FirstByte_of_isSome_utf8DecodeChar? h)).byteIdx := by
1481+
((b[i]'(lt_size_of_isSome_utf8DecodeChar? h)).utf8ByteSize (isUTF8FirstByte_of_isSome_utf8DecodeChar? h)).byteIdx := by
14821482
rw [← Char.byteIdx_utf8ByteSize_getElem_utf8EncodeChar]
14831483
simp only [List.getElem_eq_getElem_toByteArray, utf8EncodeChar_utf8DecodeChar]
14841484
simp [ByteArray.getElem_extract]

src/Init/Data/String/Pattern/Basic.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ where
8888
have hr := by
8989
simp [Pos.Raw.le_iff] at h h2 ⊢
9090
omega
91-
if lhs.getUtf8Byte (lstart + curr) hl == rhs.getUtf8Byte (rstart + curr) hr then
91+
if lhs.getUTF8Byte (lstart + curr) hl == rhs.getUTF8Byte (rstart + curr) hr then
9292
go curr.inc
9393
else
9494
false

src/Init/Data/String/Pattern/String.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ partial def buildTable (pat : Slice) : Array String.Pos.Raw :=
3939
where
4040
go (pos : String.Pos.Raw) (table : Array String.Pos.Raw) :=
4141
if h : pos < pat.utf8ByteSize then
42-
let patByte := pat.getUtf8Byte pos h
42+
let patByte := pat.getUTF8Byte pos h
4343
let distance := computeDistance table[table.size - 1]! patByte table
44-
let distance := if patByte = pat.getUtf8Byte! distance then distance.inc else distance
44+
let distance := if patByte = pat.getUTF8Byte! distance then distance.inc else distance
4545
go pos.inc (table.push distance)
4646
else
4747
table
4848

4949
computeDistance (distance : String.Pos.Raw) (patByte : UInt8) (table : Array String.Pos.Raw) :
5050
String.Pos.Raw :=
51-
if distance > 0 && patByte != pat.getUtf8Byte! distance then
51+
if distance > 0 && patByte != pat.getUTF8Byte! distance then
5252
computeDistance table[distance.byteIdx - 1]! patByte table
5353
else
5454
distance
@@ -62,7 +62,7 @@ def iter (s : Slice) (pat : Slice) : Std.Iter (α := ForwardSliceSearcher s) (Se
6262

6363
partial def backtrackIfNecessary (pat : Slice) (table : Array String.Pos.Raw) (stackByte : UInt8)
6464
(needlePos : String.Pos.Raw) : String.Pos.Raw :=
65-
if needlePos != 0 && stackByte != pat.getUtf8Byte! needlePos then
65+
if needlePos != 0 && stackByte != pat.getUTF8Byte! needlePos then
6666
backtrackIfNecessary pat table stackByte table[needlePos.byteIdx - 1]!
6767
else
6868
needlePos
@@ -95,9 +95,9 @@ instance (s : Slice) : Std.Iterators.Iterator (ForwardSliceSearcher s) Id (Searc
9595
let rec findNext (startPos : String.Pos.Raw)
9696
(currStackPos : String.Pos.Raw) (needlePos : String.Pos.Raw) (h : stackPos ≤ currStackPos) :=
9797
if h1 : currStackPos < s.utf8ByteSize then
98-
let stackByte := s.getUtf8Byte currStackPos h1
98+
let stackByte := s.getUTF8Byte currStackPos h1
9999
let needlePos := backtrackIfNecessary needle table stackByte needlePos
100-
let patByte := needle.getUtf8Byte! needlePos
100+
let patByte := needle.getUTF8Byte! needlePos
101101
if stackByte != patByte then
102102
let nextStackPos := s.findNextPos currStackPos h1 |>.offset
103103
let res := .rejected (s.pos! startPos) (s.pos! nextStackPos)

src/Init/Data/String/Slice.lean

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ def eqIgnoreAsciiCase (s1 s2 : Slice) : Bool :=
688688
where
689689
go (s1 : Slice) (s1Curr : String.Pos.Raw) (s2 : Slice) (s2Curr : String.Pos.Raw) : Bool :=
690690
if h : s1Curr < s1.utf8ByteSize ∧ s2Curr < s2.utf8ByteSize then
691-
let c1 := (s1.getUtf8Byte s1Curr h.left).toAsciiLower
692-
let c2 := (s2.getUtf8Byte s2Curr h.right).toAsciiLower
691+
let c1 := (s1.getUTF8Byte s1Curr h.left).toAsciiLower
692+
let c2 := (s2.getUTF8Byte s2Curr h.right).toAsciiLower
693693
if c1 == c2 then
694694
go s1 s1Curr.inc s2 s2Curr.inc
695695
else
@@ -900,12 +900,12 @@ instance [Pure m] : Std.Iterators.Iterator ByteIterator m UInt8 where
900900
∃ h1 : it.internalState.offset < it.internalState.s.utf8ByteSize,
901901
it.internalState.s = it'.internalState.s ∧
902902
it'.internalState.offset = it.internalState.offset.inc ∧
903-
it.internalState.s.getUtf8Byte it.internalState.offset h1 = out
903+
it.internalState.s.getUTF8Byte it.internalState.offset h1 = out
904904
| .skip _ => False
905905
| .done => ¬ it.internalState.offset < it.internalState.s.utf8ByteSize
906906
step := fun ⟨s, offset⟩ =>
907907
if h : offset < s.utf8ByteSize then
908-
pure ⟨.yield ⟨s, offset.inc⟩ (s.getUtf8Byte offset h), by simp [h]⟩
908+
pure ⟨.yield ⟨s, offset.inc⟩ (s.getUTF8Byte offset h), by simp [h]⟩
909909
else
910910
pure ⟨.done, by simp [h]⟩
911911

@@ -981,7 +981,7 @@ instance [Pure m] : Std.Iterators.Iterator RevByteIterator m UInt8 where
981981
it.internalState.s = it'.internalState.s ∧
982982
it.internalState.offset ≠ 0
983983
it'.internalState.offset = it.internalState.offset.dec ∧
984-
it.internalState.s.getUtf8Byte it.internalState.offset.dec h1 = out
984+
it.internalState.s.getUTF8Byte it.internalState.offset.dec h1 = out
985985
| .skip _ => False
986986
| .done => it.internalState.offset = 0
987987
step := fun ⟨s, offset, hinv⟩ =>
@@ -994,7 +994,7 @@ instance [Pure m] : Std.Iterators.Iterator RevByteIterator m UInt8 where
994994
simp [String.Pos.Raw.le_iff, nextOffset] at hinv ⊢
995995
omega
996996
have hiter := by simp [nextOffset, hbound, h]
997-
pure ⟨.yield ⟨s, nextOffset, hinv⟩ (s.getUtf8Byte nextOffset hbound), hiter⟩
997+
pure ⟨.yield ⟨s, nextOffset, hinv⟩ (s.getUTF8Byte nextOffset hbound), hiter⟩
998998
else
999999
pure ⟨.done, by simpa using h⟩
10001000

src/Init/Data/ToString/Name.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ namespace Lean.Name
2626
-- If you change this, also change the corresponding function in `Init.Meta`.
2727
private partial def needsNoEscapeAsciiRest (s : String) (i : Nat) : Bool :=
2828
if h : i < s.utf8ByteSize then
29-
let c := s.getUtf8Byte ⟨i⟩ h
29+
let c := s.getUTF8Byte ⟨i⟩ h
3030
isIdRestAscii c && needsNoEscapeAsciiRest s (i + 1)
3131
else
3232
true
3333

3434
-- If you change this, also change the corresponding function in `Init.Meta`.
3535
@[inline] private def needsNoEscapeAscii (s : String) (h : s.utf8ByteSize > 0) : Bool :=
36-
let c := s.getUtf8Byte 0 h
36+
let c := s.getUTF8Byte 0 h
3737
isIdFirstAscii c && needsNoEscapeAsciiRest s 1
3838

3939
-- If you change this, also change the corresponding function in `Init.Meta`.

src/Init/Meta/Defs.lean

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,6 @@ def isInaccessibleUserName : Name → Bool
156156
| Name.num p _ => isInaccessibleUserName p
157157
| _ => false
158158

159-
-- FIXME: `getUtf8Byte` is in `Init.Data.String.Extra`, which causes an import cycle with
160-
-- `Init.Meta`. Moving `getUtf8Byte` up to `Init.Data.String.Basic` creates another import cycle.
161-
-- Please replace this definition with `getUtf8Byte` when the string refactor is through.
162-
@[extern "lean_string_get_byte_fast"]
163-
private opaque getUtf8Byte' (s : @& String) (n : Nat) (h : n < s.utf8ByteSize) : UInt8
164-
165159
section ToString
166160

167161
/-!
@@ -177,14 +171,14 @@ inner-loop function like `Name.toString`.
177171
-- If you change this, also change the corresponding function in `Init.Data.ToString.Name`.
178172
private partial def needsNoEscapeAsciiRest (s : String) (i : Nat) : Bool :=
179173
if h : i < s.utf8ByteSize then
180-
let c := getUtf8Byte' s i h
174+
let c := String.Internal.getUTF8Byte s i h
181175
isIdRestAscii c && needsNoEscapeAsciiRest s (i + 1)
182176
else
183177
true
184178

185179
-- If you change this, also change the corresponding function in `Init.Data.ToString.Name`.
186180
@[inline] private def needsNoEscapeAscii (s : String) (h : s.utf8ByteSize > 0) : Bool :=
187-
let c := getUtf8Byte' s 0 h
181+
let c := String.Internal.getUTF8Byte s 0 h
188182
isIdFirstAscii c && needsNoEscapeAsciiRest s 1
189183

190184
-- If you change this, also change the corresponding function in `Init.Data.ToString.Name`.

src/Init/Prelude.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,7 +3378,7 @@ def List.utf8Encode (l : List Char) : ByteArray :=
33783378
Note that in order for this definition to be well-behaved it is necessary to know that this `m`
33793379
is unique. To show this, one defines UTF-8 decoding and shows that encoding and decoding are
33803380
mutually inverse. -/
3381-
inductive ByteArray.IsValidUtf8 (b : ByteArray) : Prop
3381+
inductive ByteArray.IsValidUTF8 (b : ByteArray) : Prop
33823382
/-- Show that a byte -/
33833383
| intro (m : List Char) (hm : Eq b (List.utf8Encode m))
33843384

@@ -3393,10 +3393,10 @@ modifications when the reference to the string is unique.
33933393
structure String where ofByteArray ::
33943394
/-- The bytes of the UTF-8 encoding of the string. Since strings have a special representation in
33953395
the runtime, this function actually takes linear time and space at runtime. For efficient access
3396-
to the string's bytes, use `String.utf8ByteSize` and `String.getUtf8Byte`. -/
3396+
to the string's bytes, use `String.utf8ByteSize` and `String.getUTF8Byte`. -/
33973397
bytes : ByteArray
33983398
/-- The bytes of the string form valid UTF-8. -/
3399-
isValidUtf8 : ByteArray.IsValidUtf8 bytes
3399+
isValidUTF8 : ByteArray.IsValidUTF8 bytes
34003400

34013401
attribute [extern "lean_string_to_utf8"] String.bytes
34023402
attribute [extern "lean_string_from_utf8_unchecked"] String.ofByteArray

src/Lean/Data/Json/Printer.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private def needEscape (s : String) : Bool :=
6464
where
6565
go (s : String) (i : Nat) : Bool :=
6666
if h : i < s.utf8ByteSize then
67-
let byte := s.getUtf8Byte ⟨i⟩ h
67+
let byte := s.getUTF8Byte ⟨i⟩ h
6868
have h1 : byte.toNat < 256 := UInt8.toNat_lt_size byte
6969
have h2 : escapeTable.val.size = 256 := escapeTable.property
7070
if escapeTable.val.get byte.toNat (Nat.lt_of_lt_of_eq h1 h2.symm) == 0 then

0 commit comments

Comments
 (0)