Bug 180753 - makeString: add single-character helpers
Summary: makeString: add single-character helpers
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 180720
Blocks:
  Show dependency treegraph
 
Reported: 2017-12-13 09:42 PST by JF Bastien
Modified: 2020-01-26 20:51 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description JF Bastien 2017-12-13 09:42:47 PST
It's neat how we do RawPointer(...) when trying to print (so we don't inadvertently pass a pointer). We should do the same thing for raw characters, especially considering that right now `unsigned short` just prints as a character (see test I added in #180720)!

While we're there, it would also be very neat to have makeString helpers for integer formatting such as HexInt(...) while also choosing upper-/lower-case and 0x prefix. The same can be done for left-padding (with spaces or arbitrary character) as well as alignment, etc.
Comment 1 JF Bastien 2017-12-13 09:44:58 PST
Note that we already have FormattedNumber for floating-point values.
Comment 2 Darin Adler 2017-12-13 21:04:34 PST
All good ideas. But please only add things we use.
Comment 3 Charlie Turner 2019-01-03 03:13:29 PST
I attempted the syntax for raw characters in https://bugs.webkit.org/show_bug.cgi?id=193101
Comment 4 Fujii Hironori 2019-01-06 18:20:04 PST
ICU 59 did the gutsy API breaking change typedefing UChar as char16_t.
http://site.icu-project.org/download/59
What about the idea updating WTF's copy of ICU header?
This seems a right direction?
Comment 5 Darin Adler 2020-01-26 20:51:43 PST
(In reply to Fujii Hironori from comment #4)
> ICU 59 did the gutsy API breaking change typedefing UChar as char16_t.
> http://site.icu-project.org/download/59
> What about the idea updating WTF's copy of ICU header?
> This seems a right direction?

Yes, I think that would be a good way to end up.

I think this would be a significant transition project for WebKit. On Cocoa platforms, the types for Unicode characters in Core Foundation and Foundation, UniChar and unichar, are both typedefs for unsigned short. Thus there are many places where we use UChar, UniChar, and unichar interchangeably. Most of those would need to change.

I think we've been careful to only use the C functions in ICU with C linkage, so we wouldn't have the most obvious kinds of runtime incompatibility issues, like mangled function names being different.