pyuno: uno.Char is UTF-16 code unit, not UCS-4
Check for that in ctor. Change-Id: Ia69b3d87ac4ccb5b6cc13169d7022c04607c609f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108803 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
This commit is contained in:
parent
33b8f7c10b
commit
c7568cfdec
@ -225,9 +225,9 @@ class Char:
|
|||||||
|
|
||||||
Use an instance of this class to explicitly pass a char to UNO.
|
Use an instance of this class to explicitly pass a char to UNO.
|
||||||
|
|
||||||
For Python 2, this class only works with unicode objects. Creating
|
For Python 3, this class only works with unicode (str) objects. Creating
|
||||||
a Char instance with a normal str object or comparing a Char instance
|
a Char instance with a bytes object or comparing a Char instance
|
||||||
to a normal str object will raise an AssertionError.
|
to a bytes object will raise an AssertionError.
|
||||||
|
|
||||||
:param value: A Unicode string with length 1
|
:param value: A Unicode string with length 1
|
||||||
"""
|
"""
|
||||||
@ -236,6 +236,7 @@ class Char:
|
|||||||
assert isinstance(value, str), "Expected str object, got %s instead." % type(value)
|
assert isinstance(value, str), "Expected str object, got %s instead." % type(value)
|
||||||
|
|
||||||
assert len(value) == 1, "Char value must have length of 1."
|
assert len(value) == 1, "Char value must have length of 1."
|
||||||
|
assert ord(value[0]) <= 0xFFFF, "Char value must be UTF-16 code unit"
|
||||||
|
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user