mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) Fix CONCAT function that was breaking on presence of non-ascii characters
Summary: This was the only occurrence of the unicode() function that I could find. Test Plan: Added a doctest case. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2750
This commit is contained in:
parent
3f29baaded
commit
2b71cce88b
@ -56,7 +56,7 @@ def CODE(string):
|
||||
def CONCATENATE(string, *more_strings):
|
||||
"""
|
||||
Joins together any number of text strings into one string. Also available under the name
|
||||
`CONCAT`. Same as the Python expression `"".join(array_of_strings)`.
|
||||
`CONCAT`. Similar to the Python expression `"".join(array_of_strings)`.
|
||||
|
||||
>>> CONCATENATE("Stream population for ", "trout", " ", "species", " is ", 32, "/mile.")
|
||||
u'Stream population for trout species is 32/mile.'
|
||||
@ -64,13 +64,32 @@ def CONCATENATE(string, *more_strings):
|
||||
u'In 4 days it is 2016-01-01'
|
||||
>>> CONCATENATE("abc")
|
||||
u'abc'
|
||||
>>> CONCATENATE(0, "abc")
|
||||
u'0abc'
|
||||
>>> CONCATENATE(2, " crème ", "brûlée".decode('utf8')) == "2 crème brûlée".decode('utf8')
|
||||
True
|
||||
"""
|
||||
return u''.join(val if isinstance(val, unicode) else str(val).decode('utf8')
|
||||
for val in (string,) + more_strings)
|
||||
|
||||
|
||||
def CONCAT(string, *more_strings):
|
||||
"""
|
||||
Joins together any number of text strings into one string. Also available under the name
|
||||
`CONCATENATE`. Similar to the Python expression `"".join(array_of_strings)`.
|
||||
|
||||
>>> CONCAT("Stream population for ", "trout", " ", "species", " is ", 32, "/mile.")
|
||||
u'Stream population for trout species is 32/mile.'
|
||||
>>> CONCAT("In ", 4, " days it is ", datetime.date(2016,1,1))
|
||||
u'In 4 days it is 2016-01-01'
|
||||
>>> CONCAT("abc")
|
||||
u'abc'
|
||||
>>> CONCAT(0, "abc")
|
||||
u'0abc'
|
||||
>>> CONCAT(2, " crème ", "brûlée".decode('utf8')) == "2 crème brûlée".decode('utf8')
|
||||
True
|
||||
"""
|
||||
return u''.join(unicode(val) for val in (string,) + more_strings)
|
||||
|
||||
|
||||
CONCAT = CONCATENATE
|
||||
return CONCATENATE(string, *more_strings)
|
||||
|
||||
|
||||
def DOLLAR(number, decimals=2):
|
||||
|
Loading…
Reference in New Issue
Block a user