![]() |
|
Help: Issues with the _PRINTSTRING and _INPUTBOX$ functions in QB64. - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Help: Issues with the _PRINTSTRING and _INPUTBOX$ functions in QB64. (/showthread.php?tid=4209) |
Help: Issues with the _PRINTSTRING and _INPUTBOX$ functions in QB64. - qbfans - 12-14-2025 During my study of QB64, I've encountered two confusing issues: _PRINTSTRING: When used within a VIEW viewport, it doesn't seem to support relative coordinates, whereas _UPRINTSTRING works fine with them. Given how similar they are, it seems like _PRINTSTRING should also be able to use relative coordinates. Chinese input via _INPUTBOX$: I can input Chinese characters normally in the pop-up dialog, but the returned string is garbled. Typically, a Chinese character in GBK encoding is 2 bytes, but the string returned by this function appears to be 4 bytes per character. The character encoding doesn't seem to match GBK, UTF-8, or UTF-16, making it impossible to convert and use correctly. While _MESSAGEBOX can normally display Chinese text, the characters returned by _INPUTBOX$ cannot even be displayed properly by the _MESSAGEBOX statement. I hope to get some help from everyone. Thank you. Code: (Select All)
![]() ![]()
RE: Help: Issues with the _PRINTSTRING and _INPUTBOX$ functions in QB64. - SpriggsySpriggs - 12-14-2025 You will most likely need to do your own implementation of the input box. RE: Help: Issues with the _PRINTSTRING and _INPUTBOX$ functions in QB64. - qbfans - 02-13-2026 Thank you everyone. I don’t have the ability to rewrite complex code — I saw the InputBox implementation on the QB64.com forum, and the code was too complicated for me. Recently, I had some time to revisit the issue of garbled characters returned by InputBox$, and I discovered there is still a pattern. My guess is that QB64 encounters issues when parsing double-byte Chinese characters during encoding conversion. The specific pattern is as follows: When X ≥ 192 (0xC0): First byte = 195, second byte = 128 + (X - 192) When 128 ≤ X < 192: First byte = 194, second byte = X Reverse conversion (fix function): If the first byte = 195: Original GBK byte = 192 + (second byte - 128) If the first byte = 194: Original GBK byte = second byte Since the mapping is this simple, handling it becomes straightforward. Code: (Select All)
Code: (Select All)
The example below is just a simple demonstration — it takes a straightforward approach. In practice, more checks and handling may be needed.This code probably won’t be testable or useful for our Latin-alphabet friends, but I’m posting it here for anyone who might need it. Additionally, I believe this is a bug in the function itself. I hope the development team can fix it and improve this otherwise very useful built-in function. |