I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8. I am getting the following error when users try to insert text in the database containing £ signs: ERROR: invalid byte sequence for encoding "UTF8": 0xa3 This is due to the encoding of a £ sign in the text being sent to the DB. My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format? Regards Garry
--On 26. Juni 2008 14:09:50 +0000 Garry Saddington <garry@schoolteachers.co.uk> wrote:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8. I am getting the following error when users try to insert text in the database containing £ signs: ERROR: invalid byte sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB. My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format? Regards
Use ensure that the HTML page uses UTF-8 as encoding (either using <meta-equiv...> within the HTML page or by sending content-type: text/html; charset=utf-8 as HTTP header. Andreas
On Thursday 26 June 2008 15:12, Andreas Jung wrote:
--On 26. Juni 2008 14:09:50 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8. I am getting the following error when users try to insert text in the database containing £ signs: ERROR: invalid byte sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB. My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format? Regards
Use ensure that the HTML page uses UTF-8 as encoding (either using <meta-equiv...> within the HTML page or by sending
content-type: text/html; charset=utf-8
as HTTP header.
I have taken this a little further after trying all suggestions in the thread with no success and looked into zope.conf, specifically: # Directive: default_zpublisher_encoding # # Description: # This controls what character set is used to encode unicode # data that reaches ZPublisher without any other specified encoding. # # Default: iso-8859-15 # # Example: # # default_zpublisher_encoding utf-8 As my pages all report as iso-8859-15 I thought a change here would help, but this happens: from OFS.content_types import guess_content_type Error: 'default_zpublisher_encoding' is not a known key name It works on this: Zope Version (Zope 2.9.0, python 2.4.2, win32) And fails on this: Zope Version (Zope 2.9.0-, python 2.4.5, linux2) Any further help would be appreciated. regards Garry ps. just noticed the typo (not mine) in zope.conf - default_zpublisher_encoding should be default-zpublisher-encoding all sorted
I would advice against relying on default-zpublisher-encoding. I never used that. By specifying the encoding like this "variablename:utf8:ustring" you override whatever default-zpublisher-encoding was set to. If you rely on default-zpublisher-encoding your product isn't installable somewhere in another zope without explicit instructions and it might clash with other things installed. Remember, it's just a default. 2008/6/26 Garry Saddington <garry@schoolteachers.co.uk>:
On Thursday 26 June 2008 15:12, Andreas Jung wrote:
--On 26. Juni 2008 14:09:50 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database
encoding is UTF8. I am getting the following error when users try to
insert text in the database containing £ signs: ERROR: invalid byte
sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB.
My question then is how do I make sure that all encodings submiitted from
forms are in the correct UTF8 format? Regards
Use ensure that the HTML page uses UTF-8 as encoding
(either using <meta-equiv...> within the HTML page or by sending
content-type: text/html; charset=utf-8
as HTTP header.
I have taken this a little further after trying all suggestions in the thread with no success and looked into zope.conf, specifically:
# Directive: default_zpublisher_encoding
#
# Description:
# This controls what character set is used to encode unicode
# data that reaches ZPublisher without any other specified encoding.
#
# Default: iso-8859-15
#
# Example:
#
# default_zpublisher_encoding utf-8
As my pages all report as iso-8859-15 I thought a change here would help, but this happens:
from OFS.content_types import guess_content_type
Error: 'default_zpublisher_encoding' is not a known key name
It works on this: Zope Version (Zope 2.9.0, python 2.4.2, win32)
And fails on this: Zope Version (Zope 2.9.0-, python 2.4.5, linux2)
Any further help would be appreciated.
regards
Garry
ps. just noticed the typo (not mine) in zope.conf - default_zpublisher_encoding should be default-zpublisher-encoding
all sorted
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
On Friday 27 June 2008 00:23, Peter Bengtsson wrote:
I would advice against relying on default-zpublisher-encoding. I never used that. By specifying the encoding like this "variablename:utf8:ustring" you override whatever default-zpublisher-encoding was set to. If you rely on default-zpublisher-encoding your product isn't installable somewhere in another zope without explicit instructions and it might clash with other things installed. Remember, it's just a default. Yes, I know but none of the recommended ways of overriding the default worked for me. Thanks for all your help. I do not intend my product to be installed in any Zope that I do not setup/specify and not with any other product. It will be distributed with its own custom Zope/Postgres distribution. Kind regards and thanks again Garry
--On 26. Juni 2008 22:05:06 +0000 Garry Saddington <garry@schoolteachers.co.uk> wrote:
On Thursday 26 June 2008 15:12, Andreas Jung wrote:
--On 26. Juni 2008 14:09:50 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8. I am getting the following error when users try to insert text in the database containing £ signs: ERROR: invalid byte sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB. My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format? Regards
Use ensure that the HTML page uses UTF-8 as encoding (either using <meta-equiv...> within the HTML page or by sending
content-type: text/html; charset=utf-8
as HTTP header.
I have taken this a little further after trying all suggestions in the thread with no success and looked into zope.conf, specifically:
# Directive: default_zpublisher_encoding # # Description: # This controls what character set is used to encode unicode # data that reaches ZPublisher without any other specified encoding. # # Default: iso-8859-15 # # Example: # # default_zpublisher_encoding utf-8
As my pages all report as iso-8859-15 I thought a change here would help, but this happens:
from OFS.content_types import guess_content_type Error: 'default_zpublisher_encoding' is not a known key name
It works on this: Zope Version (Zope 2.9.0, python 2.4.2, win32)
And fails on this: Zope Version (Zope 2.9.0-, python 2.4.5, linux2)
Totally wrong approach modifying the zpublisher encoding here. As said you have two options: - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> with in your HTML . <tal:call define="dummy python: request.RESPONSE('content-type', 'text/html;; charset=utf-8')" /> within your template The Second solution is known to work across all browsers reliably. -aj
On Friday 27 June 2008 05:38, Andreas Jung wrote:
--On 26. Juni 2008 22:05:06 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
On Thursday 26 June 2008 15:12, Andreas Jung wrote:
--On 26. Juni 2008 14:09:50 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8. I am getting the following error when users try to insert text in the database containing £ signs: ERROR: invalid byte sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB. My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format? Regards
Use ensure that the HTML page uses UTF-8 as encoding (either using <meta-equiv...> within the HTML page or by sending
content-type: text/html; charset=utf-8
as HTTP header.
I have taken this a little further after trying all suggestions in the thread with no success and looked into zope.conf, specifically:
# Directive: default_zpublisher_encoding # # Description: # This controls what character set is used to encode unicode # data that reaches ZPublisher without any other specified encoding. # # Default: iso-8859-15 # # Example: # # default_zpublisher_encoding utf-8
As my pages all report as iso-8859-15 I thought a change here would help, but this happens:
from OFS.content_types import guess_content_type Error: 'default_zpublisher_encoding' is not a known key name
It works on this: Zope Version (Zope 2.9.0, python 2.4.2, win32)
And fails on this: Zope Version (Zope 2.9.0-, python 2.4.5, linux2)
Totally wrong approach modifying the zpublisher encoding here. As said you have two options:
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> with in your HTML
. <tal:call define="dummy python: request.RESPONSE('content-type', 'text/html;; charset=utf-8')" /> within your template And if I were to use DTML? Regards Garry
--On 27. Juni 2008 06:42:28 +0000 Garry Saddington <garry@schoolteachers.co.uk> wrote:
On Friday 27 June 2008 05:38, Andreas Jung wrote:
--On 26. Juni 2008 22:05:06 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
On Thursday 26 June 2008 15:12, Andreas Jung wrote:
--On 26. Juni 2008 14:09:50 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8. I am getting the following error when users try to insert text in the database containing £ signs: ERROR: invalid byte sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB. My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format? Regards
Use ensure that the HTML page uses UTF-8 as encoding (either using <meta-equiv...> within the HTML page or by sending
content-type: text/html; charset=utf-8
as HTTP header.
I have taken this a little further after trying all suggestions in the thread with no success and looked into zope.conf, specifically:
# Directive: default_zpublisher_encoding # # Description: # This controls what character set is used to encode unicode # data that reaches ZPublisher without any other specified encoding. # # Default: iso-8859-15 # # Example: # # default_zpublisher_encoding utf-8
As my pages all report as iso-8859-15 I thought a change here would help, but this happens:
from OFS.content_types import guess_content_type Error: 'default_zpublisher_encoding' is not a known key name
It works on this: Zope Version (Zope 2.9.0, python 2.4.2, win32)
And fails on this: Zope Version (Zope 2.9.0-, python 2.4.5, linux2)
Totally wrong approach modifying the zpublisher encoding here. As said you have two options:
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> with in your HTML
. <tal:call define="dummy python: request.RESPONSE('content-type', 'text/html;; charset=utf-8')" /> within your template And if I were to use DTML?
DTML? In a similar way...You know dtml-let or something like that. You know that stuff like 'request' 'context' etc. is available in PythonScripts, ZPT and DTML is some way...everything is the same object. -aj
On Friday 27 June 2008 07:42, Andreas Jung wrote:
--On 27. Juni 2008 06:42:28 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
On Friday 27 June 2008 05:38, Andreas Jung wrote:
--On 26. Juni 2008 22:05:06 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
On Thursday 26 June 2008 15:12, Andreas Jung wrote:
--On 26. Juni 2008 14:09:50 +0000 Garry Saddington
<garry@schoolteachers.co.uk> wrote:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8. I am getting the following error when users try to insert text in the database containing £ signs: ERROR: invalid byte sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB. My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format? Regards
Use ensure that the HTML page uses UTF-8 as encoding (either using <meta-equiv...> within the HTML page or by sending
content-type: text/html; charset=utf-8
as HTTP header.
I have taken this a little further after trying all suggestions in the thread with no success and looked into zope.conf, specifically:
# Directive: default_zpublisher_encoding # # Description: # This controls what character set is used to encode unicode # data that reaches ZPublisher without any other specified encoding. # # Default: iso-8859-15 # # Example: # # default_zpublisher_encoding utf-8
As my pages all report as iso-8859-15 I thought a change here would help, but this happens:
from OFS.content_types import guess_content_type Error: 'default_zpublisher_encoding' is not a known key name
It works on this: Zope Version (Zope 2.9.0, python 2.4.2, win32)
And fails on this: Zope Version (Zope 2.9.0-, python 2.4.5, linux2)
Totally wrong approach modifying the zpublisher encoding here. As said you have two options:
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> with in your HTML
. <tal:call define="dummy python: request.RESPONSE('content-type', 'text/html;; charset=utf-8')" /> within your template
And if I were to use DTML?
DTML? In a similar way...You know dtml-let or something like that. You know that stuff like 'request' 'context' etc. is available in PythonScripts, ZPT and DTML is some way...everything is the same object.
Yes, thanks for your help. Kind regards Garry
<dtml-call "request.RESPONSE('content-type', 'text/html; charset=utf-8')"> ----- Original Message ----- From: "Garry Saddington" <garry@schoolteachers.co.uk>
Totally wrong approach modifying the zpublisher encoding here. As said you have two options:
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> with in your HTML
. <tal:call define="dummy python: request.RESPONSE('content-type', 'text/html;; charset=utf-8')" /> within your template And if I were to use DTML?
Make the form input tags look like this: <input name="mystring:utf-8:ustring" /> then you'll be certain to get it into Zope as unicode under utf-8. 2008/6/26 Garry Saddington <garry@schoolteachers.co.uk>:
I am using Zope 2.9 connected to a Posgres DB via psycopg. My database encoding is UTF8.
I am getting the following error when users try to insert text in the database containing £ signs:
ERROR: invalid byte sequence for encoding "UTF8": 0xa3
This is due to the encoding of a £ sign in the text being sent to the DB.
My question then is how do I make sure that all encodings submiitted from forms are in the correct UTF8 format?
Regards
Garry
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (4)
-
Andreas Jung -
Garry Saddington -
Jaroslav Lukesh -
Peter Bengtsson