Igor Elyas wrote:
Ops
Deep in code on returned value used Python str() function and looks like:
 str(self._reader.GetString(self._idx))

You can't call str on a string if it contains non-ascii characters. :-)

(and why would you need to...)

Michael

That correct situation ?

*From:* Igor Elyas <mailto:[email protected]>
*Sent:* Wednesday, March 25, 2009 9:17 PM
*To:* [email protected] <mailto:[email protected]>
*Subject:* [IronPython] Embedding & Charsets

Hello
I'm use IronPython 2.0.1 as embedded interpreter for read data from database.
Code for create Engine:
fEngine = Python.CreateEngine();
            Ops = fEngine.CreateOperations();
            // core libs
            fEngine.Runtime.LoadAssembly(typeof(Decimal).Assembly);
fEngine.Runtime.LoadAssembly(typeof(IValue).Assembly); // loading ADO.NET driver assemblies LoadAssemblies(from v in EtlBaseCfg.BaseCfg.Element("dlls").Elements("dll") select v.Value); After that, I use generated Ipy class for read one value from specific IDbDataReader: from ETL.Common.pipes import IValuePipe
class SelectExtractor(IValuePipe):
    def __init__(self,adoreader,originId,storage):
        self._name = originId
        self._reader = adoreader
        self._idx = adoreader.GetOrdinal(self._name)
        self._transport = storage
    def Do(self, pydict):
        val = self._transport.Clone()
        if not self._reader.IsDBNull(self._idx):
            val.Data = self._reader.GetString(self._idx)
        if pydict.ContainsKey(self._name):
            pydict[self._name] = val
        else:
            pydict.Add(self._name,val)
This operation return string with Russian symbols and I get Exception: "'ascii' codec can't decode byte 0 in position 0: ordinal not in range"
How I can enable unicode .NET strings ?
Looks like I not initialize IronPython correctly, because this code in Ipy console work fine with Russian charset (Russian Windows), but not sure about other charsets. I need use .NET unicode strings.

Best regards

Igor Elyas

------------------------------------------------------------------------
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
------------------------------------------------------------------------

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


--
http://www.ironpythoninaction.com/

_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to