You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched the opened issues and there are no duplicates
Describe the bug
range_error was thrown in -fno-exceptions mode with message "wstring_convert: to_bytes error"
when input in Ubuntu
Answer From Google AI: https://share.google/aimode/RfMcAz5ELdcenXlTl
Errors during std::wstring_convert::to_bytes typically stem from invalid characters in the input wide string or configuration mismatches with the conversion facet.
Common Causes of Errors
Invalid Encoding: The most frequent cause of a std::range_error is an input string containing [unpaired surrogates](https://stackoverflow.com/questions/32182610/how-can-i-get-wstring-convertto-bytes-to-throw-a-range-error-exception) or characters that exceed the Maxcode limit of the facet.
Deprecation: std::wstring_convert was [deprecated in C++17](http://en.cppreference.com/w/cpp/locale/wstring_convert.html) due to various usability and safety issues. Modern compilers may issue warnings or require specific flags like -std=c++11 to function.
Facet Mismatches: If the facet provided to the constructor (e.g., std::codecvt_utf8) does not match the actual encoding of the wide string, the conversion will fail.
Endianness Issues: Using the wrong byte-order (Big-endian vs. Little-endian) can lead to crashes or garbled output during conversion.
How to Fix or Prevent Crashes
Use Error Initializers: To prevent a std::range_error exception, you can provide a "byte-error string" to the [wstring_convert constructor](https://learn.microsoft.com/en-us/cpp/standard-library/wstring-convert-class?view=msvc-170). If conversion fails, the method returns this string instead of throwing an exception.
Validate Source Encoding: Ensure your source files and literals are correctly encoded (e.g., using [u8 literals](https://stackoverflow.com/questions/31513578/wstring-converter-exception-when-parsing-a-c-string) like u8"text") to avoid passing invalid bytes to the converter.
Use Modern Alternatives: Because this class is deprecated, consider using dedicated libraries like ICU (International Components for Unicode) or Boost.Nowide for more robust string handling.
Check Compiler Version: Ensure you are using a compiler with full C++11 support (e.g., GCC 4.9+), as earlier versions had buggy implementations of these facets
Code sample
Code
importfletasftfromfletimportTextFielddefmain(page: ft.Page):
new_text=TextField(hint_text="Input some wstring")
page.add(new_text)
ft.run(main)
To reproduce
When input some Chinese characters in text filed.
Expected behavior
No response
Screenshots / Videos
CapturesScreencast.from.2026-04-04.01-00-50.mp4
Operating System
Linux
Operating system details
Ubuntu 24.04.4 LTS
Flet version
0.82.2
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
Logs
range_error was thrown in -fno-exceptions mode with message "wstring_convert: to_bytes error"
Additional details
Input method IBus Table 1.17.4
Also happen in Android.
Duplicate Check
Describe the bug
range_error was thrown in -fno-exceptions mode with message "wstring_convert: to_bytes error"
when input in Ubuntu
Answer From Google AI:
https://share.google/aimode/RfMcAz5ELdcenXlTl
Errors during std::wstring_convert::to_bytes typically stem from invalid characters in the input wide string or configuration mismatches with the conversion facet.
Common Causes of Errors
How to Fix or Prevent Crashes
Code sample
Code
To reproduce
When input some Chinese characters in text filed.
Expected behavior
No response
Screenshots / Videos
Captures
Screencast.from.2026-04-04.01-00-50.mp4
Operating System
Linux
Operating system details
Ubuntu 24.04.4 LTS
Flet version
0.82.2
Regression
I'm not sure / I don't know
Suggestions
No response
Logs
Logs
range_error was thrown in -fno-exceptions mode with message "wstring_convert: to_bytes error"Additional details
Input method IBus Table 1.17.4
Also happen in Android.