logoalt Hacker News

bearttoday at 12:19 AM1 replyview on HN

How do you safely convert a 2 byte character to a 1 byte character?


Replies

jiggawattstoday at 12:36 AM

Easily! If it doesn't convert successfully because it includes characters outside of the range of the target codepage then the equality condition is necessarily false, and the engine should short-circuit and return an empty set.