Use alloc_c_string() to convert String to char*

Using get_data() would sometimes result in the wrong data being written.

Fixes #12
This commit is contained in:
Leroy Hopson 2020-11-07 17:12:31 +07:00 committed by Leroy Hopson
parent 43df7d5331
commit 399acf00c7
2 changed files with 5 additions and 3 deletions

View file

@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Positioned background rect at 0,0 so it is no longer offset if a margin is added when Terminal is a child of a Container node.
- Removed all pre-compiled binaries using BFG [Repo-Cleaner](https://rtyley.github.io/bfg-repo-cleaner/), thus re-writing git history.
### Fixed
- Fixed #12 where incorrect data would sometimes be written to the terminal when passing a string to the Terminal's `write()` method.
## [1.0.0] - 2020-10-05
### Added
- Changelog.

View file

@ -585,9 +585,8 @@ void Terminal::write(Variant data)
case Variant::Type::STRING:
{
String string = data;
CharString utf8 = string.utf8();
u8 = utf8.get_data();
len = utf8.length();
u8 = string.alloc_c_string();
len = strlen(u8);
break;
}
default: