Comments (4)
Pros:
- much less heavyweight than SDL_iconv
- people rolling their own will either get it wrong, or get it really wrong by casting to char.
Cons:
...?
from sdl.
Dumb questions:
- What should this do with too-large values? A value > 0x10FFFF not only isn't a valid Unicode codepoint, it also won't fit in a UTF-8 4-byte sequence. The current code just generates a 4-byte sequence with apparently-random bits.
- Should it fail if they try to encode a UTF-16 surrogate codepoint? I'd say yes, but right now it does not.
I'm thinking in both cases this should either encode an SDL_INVALID_UNICODE_CODEPOINT
instead (which is the Unicode REPLACEMENT CHARACTER: that weird question mark diamond shape thing we've all seen at some point), or report an error in some way, or both.
from sdl.
Dumb questions:
- What should this do with too-large values? A value > 0x10FFFF not only isn't a valid Unicode codepoint, it also won't fit in a UTF-8 4-byte sequence. The current code just generates a 4-byte sequence with apparently-random bits.
- Should it fail if they try to encode a UTF-16 surrogate codepoint? I'd say yes, but right now it does not.
I'm thinking in both cases this should either encode an
SDL_INVALID_UNICODE_CODEPOINT
instead (which is the Unicode REPLACEMENT CHARACTER: that weird question mark diamond shape thing we've all seen at some point), or report an error in some way, or both.
Agreed.
from sdl.
I'm thinking in both cases this should either encode an SDL_INVALID_UNICODE_CODEPOINT instead (which is the Unicode REPLACEMENT CHARACTER: that weird question mark diamond shape thing we've all seen at some point), or report an error in some way, or both.
Went with the first one; the pattern char *end = SDL_UCS4ToUTF8(ch, an_array_not_a_pointer); *end = 0;
was the primary way we were using this, so reporting an error would be awkward and probably unnecessary.
from sdl.
Related Issues (20)
- Embed a SDL window by NativeControlHost control in AvaloniaUI, mouse cursor don't restore to default on Linux x11. HOT 1
- Feature request SDL_EVENT_FINGER_CANCELLED
- MFC window, pop a sdl window, break! HOT 1
- Decide and Document how planar data is stored in / accessed from Surfaces
- Always prefer downscaling in SDL_GetSurfaceImage HOT 3
- [SDL2] VITA: Can't create any render at all HOT 2
- [macos] HIDAPI device disconnected while opening
- testcamera prints irrelevant debug message on exit (Windows) HOT 1
- All standard SDL properties should be namespaced HOT 2
- SDL_EnumerateDirectory fails if it hits a file currently in use HOT 3
- SDL_WarpMouseInWindow has buggy behaviour on wayland HOT 3
- How does SDL2 implement testffmpeg.c HOT 1
- Mouse cursor remains visible SDL2-2.30.x ( xwayland ) HOT 1
- Should RWseek(0, RW_SEEK_CUR) be optimized? HOT 3
- Retrobit Sega Saturn Wireless Contoller has invalid parameters HOT 4
- SDL_Event.key and kdevice does not return expected IDs? HOT 12
- testcamera does not work on emscripten HOT 2
- [Feature Request] Add Handheld and Custom device capability and feature support
- SDL_DestroyTexture leak memory wayland X11. HOT 2
- SDL3 Android SIGSEGV in `ANDROID_JoystickRumble` after `SDL_Quit` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdl.