Sorry. I passed some UTF-8 text to the django.contrib.markup.templatetags.markup.markdown function (which is included with django), and got what appeared to be an incorrectly encoded string in return.
I thought this MIGHT be a bug with the django markdown function. If it was, then I would log it. From what you suggested, it appears that it is a bug with the underlying markdown library, and not the django markdown function. Therefore, I won't log it. I apologize for the noise this added to the list, and will be more circumspect in the future when trying to contribute to improving django. mike Waylan Limberg wrote: > This appears to be a usage question. This list is for the development > of Django itself, not developing projects that use Django. Usage > questions should be directed to the django-users list [1]. > > [1]: http://groups.google.com/group/django-users > > That said, it appears that you are taking issue with markdown, which > is a separate library not included with django. Issues with markdown > should be addressed on that projects mailing list [2]. However, keep > in mind that markdown knows (almost) nothing about encodings. It only > works with unicode (or ascii) text. You *must* give markdown unicode > text and it *only* outputs unicode text. It is your responsibility to > deal with whatever encodings you need. It would be almost imposable > for markdown to support every possibility, so it doesn't even try. > > [2]: > http://sourceforge.net/mailarchive/forum.php?forum_name=python-markdown-discuss > > However, Django does have some handy mechanisms [3] for dealing with > this sort of thing. You might want to check them out. > > [3]: http://www.djangoproject.com/documentation/unicode/ > > Also, why are you importing markdown from the template filter? Why not > just import markdown directly? > > On Wed, May 21, 2008 at 2:11 PM, Mike Chambers <[EMAIL PROTECTED]> wrote: >> I just ran into an issue where i was getting unicode errors when trying >> to insert data into mysql (via a model). >> >> I had this code: >> >> -- >> from django.contrib.markup.templatetags.markup import markdown >> >> def save(self): >> self.content_html = markdown(self.content_source) >> >> super(Chapter, self).save() >> -- >> >> self.content_source is utf-8 >> >> This would cause a unicode error when the code tried to save the string >> in the DB (mysql) if content_source contained any non-ascii chars. >> >> I was able to fix this by explicitly setting the encoding on the string >> returned from markdown() >> >> -- >> from django.contrib.markup.templatetags.markup import markdown >> >> def save(self): >> self.content_html = markdown(self.content_source).encode("utf-8") >> >> super(Chapter, self).save() >> -- >> >> However, I would have expected the markdown function to return the >> correctly encoded string. >> >> Here is a simple script that I believe shows the difference in output: >> >> -- >> from django.contrib.markup.templatetags.markup import markdown >> >> tmp = u'Andr\202' >> m = markdown(tmp) >> print m >> m = markdown(tmp).encode("utf-8") >> print m >> -- >> >> Python 2.5.1 (r251:54863, Jan 17 2008, 19:35:17) >> django.VERSION (0, 97, 'pre') >> >> I am pretty new to django, and dont have much experience working with >> unicode, so I wanted to post here to see if anyone thought that this >> looked like a bug? If so I will log it. >> >> mike >> >> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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-developers?hl=en -~----------~----~----~----~------~----~------~--~---