Hi,
Since a few days I am writing StarBasic custom functions for Calc wich call
external Python functions.
Yesterday I found this error:
-----------------------------------------------------------
BASIC runtime error.
An exception occurred
Type: com.sun.star.uno.RuntimeException
Message: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\ufffd' in position 3: ordinal not in range(128), traceback follows
------------------------------------------------------------
I bypassed it in Python with
tmp = dTlx[isin]['descrizione_masterchart']
tmp = tmp.replace(u'\ufffd',"?")
But I think the problem can arrive in other forms, since there can be other unicode characters
in the text i have in my database and here it seems like StarBasic is trying to convert the string to ASCII.
Do you know if it is possible for StarBasic to accept unicode strings from Python ?
I include the string receiving Basic function
Function msDescrizioneMasterchart(v1, v2) as String
Dim oScriptProvider, oScript
scriptUrl = "vnd.sun.star.script:masterchart.py$msDescrizioneMasterchart?language=Python&location=user"
oScriptProvider = ThisComponent.getScriptProvider()
oScript = oScriptProvider.getScript(scriptUrl)
Dim out as String
out = oScript.invoke(array(v1,v2), array(), array())
msDescrizioneMasterchart = out
End Function