-
-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Wide String Constants Prefix #1965
base: master
Are you sure you want to change the base?
Conversation
One additional comment: I am aware that this is really only a 16-bit conversion abstraction for 8-bit characters right now ( I would certainly be willing to help make the conversion for strings better and more friendly for those use-cases, preferably with some help from someone with a bit more knowledge about that. Thanks. |
Yes, as you know I think this is better as a builtin function to convert it. The reason it can be a builtin is that it could be a macro. The code as written looks nice, however I think mostly people would use L"..." to get an array of ushort instead. Alternatively it's supposed to be the platform wide character which is 32 on MacOS and 16 on Windows I think. |
While trying to fix the test cases, I think I might adjust the direction of this change to make it more explicit and universally-applicable, rather than having the expansion of the string depend upon the target platform and simply trying to cram in my Exactly as you mentioned, from the GNU C Language Manual:
From this article... // This will generally use some kind of Unicode encoding, but the
// exact encoding will be different on different platforms. On
// Windows, UTF-16. On Linux and Mac, UTF-32.
const wchar_t *wstr = L"γειά σου κόσμος"; So I'm going to write in the
Confusingly, the linked article above mentions the I guess I need to learn more about parsing these things and also find out what c3c already has in terms of Unicode support. If you have anything to add on for this quest, I'd appreciate it. |
I took this as a challenge and really rolled with it. Added Despite the tests all passing on my local machine, there is one peculiar problem that remains after this change: the size of the data arrays remains at what a char array would have been, and I cannot figure out how to emit the right array size for the dynamic data type and carry over the entire For example, You can see this problem whenever you don't use dynamic array sizes during variable creation/assignments. Any help on this part would be awesome. |
Adds wide-string constants to the language, e.g.
char[?] my_string = L"Each character is 16 bytes wide! Escapes\t are understood!";
This is an analog to an existing (albeit obscure) C feature, which I referenced in my open issue: #1947
I did my best here to conform to code styling/requirements, but please feel free to clean things up or stress-test them.
@lerno I know you said you were going to make a builtin, but I wanted to try my hand at modifying the compiler and writing a test. Go easy on me. If you don't want this feature in the language, I understand, but this was great to get my hands into the compiler anyway!