r/compsci • • May 17 '19

20+ String Coding Interview Questions for Programmers

https://hackernoon.com/20-string-coding-interview-questions-for-programmers-6b6735b6d31c
113 Upvotes

41 comments sorted by

View all comments

19

u/icendoan May 17 '19

strings are an array of characters

Not in utf8, they're not. Ascii is not the be all and end all.

5

u/quentech May 17 '19

What runtimes store strings in memory as utf8?

3

u/czdl May 17 '19 edited May 17 '19

Cocoa / OSX

Windows uses UTF16 which has exactly the same issue.

0

u/quentech May 17 '19

has exactly the same issue

Windows uses fixed 16-bit width characters and string are in fact arrays of them.

1

u/nzodd May 18 '19

What do you mean, the win32 api? So how does it store characters outside the BMP then ?

1

u/masklinn May 18 '19

Same as java or JavaScript, surrogates are visible and you can easily get or create outright invalid text, even ignoring the grapheme cluster issue.