What does "itoa" stand for in strconv.Itoa?
Asked Answered
L

1

25

This might sound like a silly question... But I can't find anywhere what the "a" in strconv.Itoa actually stands for. If its taking an integer and turning it into a string, why isn't the function called Itos?

Lauro answered 4/4, 2013 at 4:45 Comment(1)
it stands for integer to ascii: #2910268Mihalco
F
44

integer to ASCII. It comes from the C language/UNIX. See this thread for more: Where did the name `atoi` come from?

In the C language, there is no concept such as strings, you have arrays of characters that are null terminated.

Thanks to @mvp!

Funderburk answered 4/4, 2013 at 4:47 Comment(5)
Also, it's called itoa because the precedent set by C to use that name for this kind of conversion.Footman
Was editing my comment to add that, when I noticed it was tagged Go. Thanks!Funderburk
this is wrong. A is coming from ASCII, not from array: #2910268Mihalco
The guys who developed Go at Google, also wrote most of Unix and Plan9. So there are many other Unix references littered throughout the documentation.Mcbee
It doesn't really make sense. It's historical baggage that the Go apis have mostly abandoned - but not in this case. Despite UTF8 adoption growing, ASCII is not yet dead, alas.Setula

© 2022 - 2024 — McMap. All rights reserved.