|
List Info
Thread: Problem with string slicing in templates on non-ascii characters
|
|
| Problem with string slicing in templates
on non-ascii characters |
  United States |
2007-05-26 17:25:24 |
Hello,
when displaying list of my arcitles, I'm displaying first
char of my
article as heading with {{ page.name.0 }}
However, for non-ascii characters, this char is crippled -
see
http:
//rpgpedia.cz/nastroje/wiki/seznam-clanku/ (bottom of
the page).
Where should the problem be? Should this be considered as
django bug?
Thank You,
Almad
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem with string slicing in
templates on non-ascii characters |

|
2007-05-26 17:59:20 |
On 5/26/07, Almad <bugs almad.net> wrote:
> However, for non-ascii characters, this char is
crippled - see
> http:
//rpgpedia.cz/nastroje/wiki/seznam-clanku/ (bottom of
the page).
You should probably use the unicode branch; Malcolm has
called for
testing, and your use case is an example of where help is
needed.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem with string slicing in
templates on non-ascii characters |
  Australia |
2007-05-26 19:36:11 |
On Sat, 2007-05-26 at 15:25 -0700, Almad wrote:
> Hello,
>
> when displaying list of my arcitles, I'm displaying
first char of my
> article as heading with {{ page.name.0 }}
>
> However, for non-ascii characters, this char is
crippled - see
> http:
//rpgpedia.cz/nastroje/wiki/seznam-clanku/ (bottom of
the page).
You are (correctly :-( ) being served the first byte from a
string of
bytes. It just happens to be half of a UTF-8 (or whetever
encoding you
are using) sequence of bytes, but Python has absolutely of
knowing that.
> Where should the problem be? Should this be considered
as django bug?
Bytestrings are not particularly useful in cases like this,
where you
want to split and join and do other string operations, so
it's not
really a bug.
As Jeremy mentioned, you'll probably get more joy out of the
unicode
branch, since it's much easier (and recommended) to use
unicode strings
everywhere there, so you don't have to worry about encoding
issues.
Slicing a unicode string as
"some_unicode_string[0]" will always give
you the first character, as a unicode character -- so you
don't have to
worry about how many bytes it takes up when encoded, because
it's not
encoded at that point.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem with string slicing in
templates on non-ascii characters |
  Australia |
2007-05-26 19:41:48 |
On Sun, 2007-05-27 at 10:36 +1000, Malcolm Tredinnick
wrote:
> On Sat, 2007-05-26 at 15:25 -0700, Almad wrote:
> > Hello,
> >
> > when displaying list of my arcitles, I'm
displaying first char of my
> > article as heading with {{ page.name.0 }}
> >
> > However, for non-ascii characters, this char is
crippled - see
> > http:
//rpgpedia.cz/nastroje/wiki/seznam-clanku/ (bottom of
the page).
>
> You are (correctly :-( ) being served the first byte
from a string of
> bytes. It just happens to be half of a UTF-8 (or
whetever encoding you
> are using) sequence of bytes, but Python has absolutely
of knowing that.
Difficult to believe I speak English as a first language.
:-(
That last sentence should end "... but Python has
absolutely no way of
knowing that."
Sorry for any confusion.
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Problem with string slicing in
templates on non-ascii characters |
  United States |
2007-05-29 09:49:20 |
Unicode branch really solved my problem. Thank You very
much.
Almad
On May 27, 2:36 am, Malcolm Tredinnick <malc... pointy-stick.com>
wrote:
> On Sat, 2007-05-26 at 15:25 -0700,Almadwrote:
> > Hello,
>
> > when displaying list of my arcitles, I'm
displaying first char of my
> > article as heading with {{ page.name.0 }}
>
> > However, for non-ascii characters, this char is
crippled - see
> >http:
//rpgpedia.cz/nastroje/wiki/seznam-clanku/(bottom of the
page).
>
> You are (correctly :-( ) being served the first byte
from a string of
> bytes. It just happens to be half of a UTF-8 (or
whetever encoding you
> are using) sequence of bytes, but Python has absolutely
of knowing that.
>
> > Where should the problem be? Should this be
considered as django bug?
>
> Bytestrings are not particularly useful in cases like
this, where you
> want to split and join and do other string operations,
so it's not
> really a bug.
>
> As Jeremy mentioned, you'll probably get more joy out
of the unicode
> branch, since it's much easier (and recommended) to use
unicode strings
> everywhere there, so you don't have to worry about
encoding issues.
> Slicing a unicode string as
"some_unicode_string[0]" will always give
> you the first character, as a unicode character -- so
you don't have to
> worry about how many bytes it takes up when encoded,
because it's not
> encoded at that point.
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-users googlegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-5]
|
|