Posted: Sat Mar 01, 2008 10:41 pm
Hi,
For a modern OS, the strlen function never correctly returns the width that the string will be on the screen because modern OSs use proportional fonts - for example, the letter 'W' is a few pixels wider than the number '1'. You need to use a font engine to determine the width of the string on the screen for ASCII and/or UTF8.
Therefore, the strlen function can be a simple "find the first zero" function and it won't matter if you're using ASCII or UTF8.
Note: I am *not* accusing anyone of writing a modern OS...
Cheers,
Brendan
For a modern OS, the strlen function correctly returns the length of a zero terminated string in bytes (for both ASCII and UTF8).SpooK wrote:PS: As for UTF-8 being internally "appropriate" in an OS, at least you will have a strlen function that will be worth the function calling overhead
For a modern OS, the strlen function never correctly returns the width that the string will be on the screen because modern OSs use proportional fonts - for example, the letter 'W' is a few pixels wider than the number '1'. You need to use a font engine to determine the width of the string on the screen for ASCII and/or UTF8.
Therefore, the strlen function can be a simple "find the first zero" function and it won't matter if you're using ASCII or UTF8.
Note: I am *not* accusing anyone of writing a modern OS...
Cheers,
Brendan