[IronPython] Embedding & Charsets
Igor Elyas
igor_elyas at hotmail.com
Wed Mar 25 20:29:39 CET 2009
Ops
Deep in code on returned value used Python str() function and looks like:
str(self._reader.GetString(self._idx))
That correct situation ?
From: Igor Elyas
Sent: Wednesday, March 25, 2009 9:17 PM
To: Users at lists.ironpython.com
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
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20090325/424f4e0a/attachment.html>
More information about the Ironpython-users
mailing list