Replies: 5 comments 2 replies
-
(By the way, I don't care about UTF-8 in my particular application, but it can happen during live coding that I accidentally hit some key combination that gives me one of these in the buffer or Vim command queue, then I'm screwed... I just want it to be replaced by |
Beta Was this translation helpful? Give feedback.
-
I remember fixing a similar issue with Zep & Imgui. Out of curiosity, what is the value of |
Beta Was this translation helpful? Give feedback.
-
My take is that we should filter these out up front, and understand why invalid characters are getting through. The UTF8 support is new and not well tested, but clearing the buffer sounds like a cludge instead of figuring out why it was corrupted initially. |
Beta Was this translation helpful? Give feedback.
-
Something that often happens on Windows is that surrogate pairs (for codepoints >= U+10000) are sent as two input events, one for the low surrogate character and one for the high surrogate. But these characters, taken individually, are indeed invalid Unicode characters. What the application input layer must do is store the surrogate character and wait until the other half is received before passing it to Zep. Not sure if this is the exact problem, but if it can be of any help, you can see more information about how I fixed this in Imgui at ocornut/imgui#2815 . The function that stores the surrogate and waits for the next one is here: https://github.com/ocornut/imgui/pull/2815/files#diff-cee9beb740469eb5192dfe94aaee7320932590adade9d9b1d2ee392ac2e1e88cR1266 |
Beta Was this translation helpful? Give feedback.
-
So, I suggest adding a test for |
Beta Was this translation helpful? Give feedback.
-
With an international keyboard, I can sometimes get an invalid UTF-8 code entered into the Zep buffer (e.g. if I type a ¨ without pressing the following (
e
) key to complete the ë). Then I get crashes because of the exception thrown inutf8::next()
(throwsinvalid_code_point(cp)
). I can catch this error, of course, but unless I "clean" the buffer somehow, it will just keep coming each time I callHandleKeyPress()
. I'm looking into something likeMultiByteToWideChar()/WideCharToMultiByte()
round trip (on Windows, at least), withGetBufferText()
andSetText()
on the ZepBuffer
, but I'm not sure if there's any nicer way you would recommend.Once this character is in the buffer (or the command buffer, in Vim mode!), I can't get rid of it. At least I can move the cursor somewhere else, and I can even comment out the bad line, but I can't delete that line or those characters, for example.
Thanks,
Glen.
Beta Was this translation helpful? Give feedback.
All reactions