mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
fix: copy/paste replaced tabs with spaces
This commit is contained in:
+27
-27
@@ -1664,18 +1664,18 @@ Casts a rune to int
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
import "core:strconv"
|
import "core:strconv"
|
||||||
rune_to_int :: proc () {
|
rune_to_int :: proc () {
|
||||||
my_int, ok := strconv.rtoi('5')
|
my_int, ok := strconv.rtoi('5')
|
||||||
if ok {
|
if ok {
|
||||||
assert(typeid_of(type_of(my_int)) == int)
|
assert(typeid_of(type_of(my_int)) == int)
|
||||||
fmt.println(my_int)
|
fmt.println(my_int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
5
|
5
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
|
|
||||||
@@ -1683,10 +1683,10 @@ Output:
|
|||||||
- ok: ok=false if input not a rune or not numeric.
|
- ok: ok=false if input not a rune or not numeric.
|
||||||
*/
|
*/
|
||||||
rtoi :: proc(r: rune) -> (value: int, ok: bool) #optional_ok {
|
rtoi :: proc(r: rune) -> (value: int, ok: bool) #optional_ok {
|
||||||
if '0' <= r && r <= '9' {
|
if '0' <= r && r <= '9' {
|
||||||
return int(r - '0'), true
|
return int(r - '0'), true
|
||||||
}
|
}
|
||||||
return -1, false
|
return -1, false
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Casts one u8 character to int
|
Casts one u8 character to int
|
||||||
@@ -1697,19 +1697,19 @@ Casts one u8 character to int
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
import "core:strconv"
|
import "core:strconv"
|
||||||
u8_to_int :: proc () {
|
u8_to_int :: proc () {
|
||||||
my_u8 := u8('8')
|
my_u8 := u8('8')
|
||||||
my_int, ok := strconv.utoi(my_u8)
|
my_int, ok := strconv.utoi(my_u8)
|
||||||
if ok {
|
if ok {
|
||||||
assert(typeid_of(type_of(my_int)) == int)
|
assert(typeid_of(type_of(my_int)) == int)
|
||||||
fmt.println(my_int)
|
fmt.println(my_int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
|
||||||
8
|
8
|
||||||
|
|
||||||
|
|
||||||
**Returns:**
|
**Returns:**
|
||||||
@@ -1718,10 +1718,10 @@ Output:
|
|||||||
- ok: ok=false if input not a u8 character or not numeric.
|
- ok: ok=false if input not a u8 character or not numeric.
|
||||||
*/
|
*/
|
||||||
utoi :: proc(u: u8) -> (value: int, ok: bool) #optional_ok {
|
utoi :: proc(u: u8) -> (value: int, ok: bool) #optional_ok {
|
||||||
if '0' <= u && u <= '9' {
|
if '0' <= u && u <= '9' {
|
||||||
return int(u - '0'), true
|
return int(u - '0'), true
|
||||||
}
|
}
|
||||||
return -1, false
|
return -1, false
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Writes a quoted string representation of the input string to a given byte slice and returns the result as a string
|
Writes a quoted string representation of the input string to a given byte slice and returns the result as a string
|
||||||
|
|||||||
Reference in New Issue
Block a user