Mailing List Archive

Zope 2.13 + MS SQL Server 2008 + UTF8
Hi again list

After have setup my zope site and database to use ISO-8859-1, I did some
test and unfortunely it fail with javascript doing AJAX calls because the
standart says that all calls must be UTF8 nevertheless the chatset in the
page.

So now I'm changing to use UTF8, but I have another problems: the data is
stored in incorrect way.
I tried to save "test áñ" but it's stored "test áñ"

My setup
-Windows 7
-Zope 2.13.23
-MS Sql server 2008


--zope.conf
rest-input-encoding utf-8
rest-output-encoding utf-8
default-zpublisher-encoding utf-8

--python file site.py
encoding = "utf-8"

--html header
<meta http-equiv="content-type" content="text/html; charset=utf-8">


The pages
* index_html (dtml-document)
containt the html FORM

*estado.html ( dtml-method)
according to a field from the FORM, it call differents pages, in this case
to "agregar.html"

* agregar.html (dtml-document)
recive the data and call the Zsql (agrega_credencial)

* agrega_credencial (zsql method)
"insert into credencial (nombre) values ( N'<dtml-sqlvar credencial
type="nb">')"

--MS SQL Server
the fields are nvarchar

--SQL Server management (admin tool)
here is were I see that the data is stored like "test áñ",


but even if I use the agrega_credencial (zsql method) using the ZMI the
data is not saved correctly.

What do I need to use UTF8 in my setup? What I'm missing?



________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida
Re: Zope 2.13 + MS SQL Server 2008 + UTF8 [ In reply to ]
2016-07-22 16:55 GMT-05:00 Miguel Beltran R. <yourpadre@gmail.com>:

>
> * agrega_credencial (zsql method)
> "insert into credencial (nombre) values ( N'<dtml-sqlvar credencial
> type="nb">')"
>
>
>


I did some changes to the zsql method to
"insert into credencial (nombre) values (N<dtml-sqlvar
"scripts.txt__py(credencial)" type="nb">)

where scripts is a folder object, and txt__py is a python script object

-- txt__py (parameter s)
try:
if s == None:
u=u''
elif same_type(s,''):
try:
u=s.decode('utf-8')
except UnicodeDecodeError:
u=s
elif same_type(s,u''):
u=s
else:
u='data not valid type'
except Exception, e:
return "error decoding"


After this change it's working like I expect. The idea came from here (1).
now the question, what it's the scope of the settings in the zope.conf file
where the enconding is set? it only affect html page render?


(1) http://pgbovine.net/unicode-python.htm


________________________________________
Lo bueno de vivir un dia mas
es saber que nos queda un dia menos de vida