@@ -1723,15 +1723,12 @@ pub fn String::length(self : String) -> Int = "%string_length"
1723
1723
pub fn String::charcode_length(self : String) -> Int = "%string_length"
1724
1724
1725
1725
///|
1726
- /// Retrieves the character at the specified index in a string. Each character in
1727
- /// the string is represented as a UTF-16 code unit.
1726
+ /// Retrieves the charcode (UTF-16 code unit) at the specified index in a string.
1728
1727
///
1729
1728
/// Parameters:
1730
1729
///
1731
- /// * `string` : The string from which to retrieve the character.
1732
- /// * `index` : The position in the string from which to retrieve the character.
1733
- ///
1734
- /// Returns the character at the specified index.
1730
+ /// * `string` : The string from which to retrieve the charcode.
1731
+ /// * `index` : The position in the string from which to retrieve the charcode.
1735
1732
///
1736
1733
/// Throws a runtime error if `index` is negative or greater than or equal to the
1737
1734
/// length of the string.
@@ -1741,8 +1738,8 @@ pub fn String::charcode_length(self : String) -> Int = "%string_length"
1741
1738
/// ```moonbit
1742
1739
/// test "String::op_get" {
1743
1740
/// let s = "Hello, 世界!"
1744
- /// inspect!(s[0], content="H ")
1745
- /// inspect!(s[7], content="世 ")
1741
+ /// inspect!(s[0].to_char() , content="Some('H') ")
1742
+ /// inspect!(s[7], content="19990 ")
1746
1743
/// }
1747
1744
///
1748
1745
/// test "panic String::op_get/out_of_bounds" {
@@ -1751,7 +1748,7 @@ pub fn String::charcode_length(self : String) -> Int = "%string_length"
1751
1748
/// }
1752
1749
/// ```
1753
1750
///
1754
- pub fn String::op_get(self : String, idx : Int) -> Char = "%string_get"
1751
+ pub fn String::op_get(self : String, idx : Int) -> Int = "%string_get"
1755
1752
1756
1753
///|
1757
1754
/// Retrieves the character at the specified index in a string.
0 commit comments