Re: Scandinavian characters in .po files and timezones

2006-08-01 Thread Maciej Bliziński

On Mon, 2006-07-31 at 20:39 -0500, Jorge Gajon wrote:
> Hi,
> 
> Take notice that there is also a 'fileencoding' setting in vim. When
> you create a new file in vim, 'fileencoding' will not be set and so it
> will take the current value from 'encoding'.

Also the variable 'fileencodings' is important. Vim will guess the
fileencoding by itself, but the encoding needs to be on the
'fileencodings' list.

I've blogged about it once:
http://automatthias.wordpress.com/2006/07/18/vim-utf-8-and-iso-8859-2/

-- 
Maciej Bliziński
http://automatthias.wordpress.com


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Scandinavian characters in .po files and timezones

2006-07-31 Thread Jorge Gajon

Hi,

Take notice that there is also a 'fileencoding' setting in vim. When
you create a new file in vim, 'fileencoding' will not be set and so it
will take the current value from 'encoding'.

When you open an existing file, vim will try to determine its encoding
and set 'fileencoding' accordingly. But be aware that if you change
the 'encoding' the 'fileencoding' variable will not be affected.

If you want to actually change the encoding of an existing file you
must change the variable 'fileencoding' and save (:w) the file.

Look at :help fileencoding   and   :help encodingfor more details.

You could also take a look at this script:
http://www.vim.org/scripts/script.php?script_id=789

Cheers,
Jorge



On 7/30/06, Mikko Nylén <[EMAIL PROTECTED]> wrote:
>
> Thanks for all answers. I was able to fix the problem by starting over with 
> the django.po. May be the problem was that when I did start working with the 
> file, I didn't have set encoding=utf-8 and when I turned it on in the middle, 
> Vim didn't convert the characters to UTF-8.
>
> - Mikko Nylén
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



RE: Scandinavian characters in .po files and timezones

2006-07-30 Thread Mikko Nylén

Thanks for all answers. I was able to fix the problem by starting over with the 
django.po. May be the problem was that when I did start working with the file, 
I didn't have set encoding=utf-8 and when I turned it on in the middle, Vim 
didn't convert the characters to UTF-8.

- Mikko Nylén


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Scandinavian characters in .po files and timezones

2006-07-30 Thread Jean-Francois Roy


On Jul 30, 2006, at 08:08, Mikko Nylén wrote:


Also, I'd like to ask how different timezones should be handled? I'm
building an application where it would be necessary for the users  
to be able
to choose their own timezone to display date and time information  
correctly.

One option would be, of course, to save the date and time returned by
datetime.utcnow() to database and then for each user have setting
"timezone", which would tell the offset from UTC in seconds.  
However, if

there are any better ways to handle this, I'd like to know about them.



You may want to have a look at http://code.djangoproject.com/ticket/ 
2447, which I recently submitted. It's not much, and probably not  
very good, but it's been working for me nicely with datetime fields  
so far.



Jean-François Roy

--
Co-Founder of MacStorm
/dev/klog. You better pipe that through your mind.

http://www.devklog.net
http://www.macstorm.org
[EMAIL PROTECTED]

http://www.devklog.net/documents/Jean-Francois_Roy.gpgkey
Fingerprint: 06CD 6F7B 4BF0 2AC6 78B2 57A3 06BE 6CB3 0591 FA2D



PGP.sig
Description: This is a digitally signed message part


Re: Scandinavian characters in .po files and timezones

2006-07-30 Thread Ian Clelland

On 7/30/06, Antonio Cavedoni <[EMAIL PROTECTED]> wrote:
> I don't know much about Vim, but it appears your ö and ä are entered
> with an encoding different than UTF-8. Python then tries to decode
> your characters thinking they might be valid UTF-8, but they are not,
> so it raises the UnicodeDecodeError.
>
> FYI: ä (LATIN SMALL LETTER A WITH DIAERESIS) in UTF-8 is \xc3\xa4,
> whereas \xe4 is its encoded form in ISO-8859-1/Latin-1 (and
> ISO-8859-10/Latin-6 as well, I haven't looked at other encodings).

It's quite possible that this is the case -- in a unix environment,
you can use the od command to see the bytewise encoding of the text
file. Use something like

  od -t x1 filename.txt

to see the individual bytes in hex.

Also, to test pythons unicode handling, try a simple file with nothing but

print u"ä"

and see how python handles the string.

> I googled a bit, and found this page [1] where it says that to set
> your Vim to the UTF-8 encoding you have to use the following command
> (note the column at the beginning):
>
> :set encoding=utf-8

The colon at the beginning of the line is to enter command mode in
vim, when you are using it interactively. It is not required in a
.vimrc file.


-- 
Regards,
Ian Clelland
<[EMAIL PROTECTED]>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Scandinavian characters in .po files and timezones

2006-07-30 Thread Antonio Cavedoni

On 30 Jul 2006, at 14:08, Mikko Nylén wrote:
> I tried to change all 'ä's with \xe4 and 'ö's with \xf6 and with  
> those I was
> able to make the messages compile. However, when trying to launch the
> built-in server, I get error saying "UnicodeDecodeError: 'utf8'  
> codec can't
> decode bytes in position 26-28: invalid data".
>
> I'm using Vim as my editor and I have set "set encoding=utf-8"  
> in .vimrc.
> Also, in the django.po I have line "Content-Type: text/plain;
> charset=utf-8". Is there something else I'm missing?

I don’t know much about Vim, but it appears your ö and ä are entered  
with an encoding different than UTF-8. Python then tries to decode  
your characters thinking they might be valid UTF-8, but they are not,  
so it raises the UnicodeDecodeError.

FYI: ä (LATIN SMALL LETTER A WITH DIAERESIS) in UTF-8 is \xc3\xa4,  
whereas \xe4 is its encoded form in ISO-8859-1/Latin-1 (and  
ISO-8859-10/Latin-6 as well, I haven’t looked at other encodings).

I googled a bit, and found this page [1] where it says that to set  
your Vim to the UTF-8 encoding you have to use the following command  
(note the column at the beginning):

:set encoding=utf-8

[1] http://www.vim.org/htmldoc/mbyte.html

> Also, I'd like to ask how different timezones should be handled? I'm
> building an application where it would be necessary for the users  
> to be able
> to choose their own timezone to display date and time information  
> correctly.
> One option would be, of course, to save the date and time returned by
> datetime.utcnow() to database and then for each user have setting
> "timezone", which would tell the offset from UTC in seconds.

Yeah, this way sounds reasonable to me.

You may also want to have a look at pytz:

http://pytz.sourceforge.net/

Cheers!
-- 
Antonio



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---