Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TextWidget/MultiLineTextWidth : Support non-ASCII characters...
...kindof. Our eventual aim is to standardise on representing text using UTF8-encoded `std::string` objects on the C++ side of things, and `unicode` objects on the Python side (see GafferHQ#1208). But here we're using UTF8 encoded `str` (bytes) objects on the Python side as well. Rationale : - Returning unicode from `getText()` now would be too much of a breaking change, potentially affecting a _lot_ of client code. The better time to make this change will be when we transition to Python 3, when `str` objects _are_ unicode, and everything will be breaking left right and centre anyway. - We've already got de facto use of UTF8 in Python anyway, because that's what we get from things like `os.listdir()` and `glob.glob()`. - The main downside of using UTF8 `str` is that when multi-byte characters are present, naive indexing will produce incorrect results. This is evident in the API for `TextWidget.getSelection()` and `TextWidget.setSelection()`, which will not match the indexing of `TextWidget.getText()`. But we don't do much character-level processing of text, so in the majority of cases this is an improvement over the status quo, where `getText()` alone was unusable (throwing an exception).
- Loading branch information