Page MenuHome

Text.current_character wrong value for certain characters
Open, Confirmed, LowPublic

Description

System Information
Operating system: Windows-10-10.0.17763 64 Bits
Graphics card: GeForce GTX 1080/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 419.17

Blender Version
Broken: version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-06-14 23:24, hash: rB0fd96b4128ff
Worked: Never. 2.79 has the same issue.

Short description of error
Property current_character and select_end_character on bpy.types.Text objects both report wrong values for some unicode characters. Some characters have a size of 2 and some have 3.

Exact steps for others to reproduce the error

  1. Open blend-file
  2. Set caret position at the end of line 13
  3. Run script and see console
  4. Set caret position at the end of line 14
  5. Run script and see console
  6. Take note of the caret position difference

[Based on the default startup or an attached .blend file (as simple as possible)]

Details

Type
Bug

Event Timeline

Philipp Oeser (lichtwerk) claimed this task.
Philipp Oeser (lichtwerk) triaged this task as Confirmed, Low priority.

Can confirm.

current_character and select_end_character are directly pointing to text DNA curc, selc (and these can indeed inherit the "error" of unicode characters having a differrent length that one...)

Guess this could be resolved by making a rna property func that takes these into account using txt_utf8_offset_to_index or BLI_str_utf8_size...
Can check [might take a bit though...]

Can confirm.
current_character and select_end_character are directly pointing to text DNA curc, selc (and these can indeed inherit the "error" of unicode characters having a differrent length that one...)
Guess this could be resolved by making a rna property func that takes these into account using txt_utf8_offset_to_index or BLI_str_utf8_size...
Can check [might take a bit though...]

The characters are unusual to come across so this isn't exactly a pressing issue, but thanks for looking into it!

Having it report correct caret position would be helpful for extending the functionality of the text editor using python.