8

Being Cellfish: Go for C# developers: Unicode strings

 1 year ago
source link: https://blog.cellfish.se/2022/11/go-for-c-developers-unicode-strings.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

2022-11-24

Go for C# developers: Unicode strings

 There are a few gotchas with strings in Go if they contain unicode characters.

For example, if you loop over a string using range to get all characters, you will actually only loop over the starting index for each character. Similarly the built in len function will return the number of bytes used in the string and not the number of visible characters.

Here is an example showing how the index variable is "jumping" to each character in the string and how accessing each character in the string using that index is not working as expected.

No comments:

Post a Comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK