awesome slugify and unicode
Mark Lawrence
breamoreboy at yahoo.co.uk
Thu Jan 23 04:14:48 EST 2014
On 23/01/2014 07:18, wxjmfauth at gmail.com wrote:
> Le mercredi 22 janvier 2014 20:23:55 UTC+1, Mark Lawrence a écrit :
>> I thought this blog might interest some of you
>>
>> http://pydanny.com/awesome-slugify-human-readable-url-slugs-from-any-string.html
>>
>> My fellow Pythonistas, ask not what our language can do for you, ask
>>
>> what you can do for our language.
>>
>
> This is not "unicode", only string manipulations.
> The same work could be done with, let say, cp1252.
> The difference lies in the repertoires of characters
> to be handled.
>
> A better way is to work with normalization() and/or
> with methods like .translate() with dedicated
> tables; the hard task being the creation of these tables.
>
> Shortly, very naive.
>
> jmf
>
You'll have to excuse my ignorance of this stuff. How do I express the
following in cp1252?
def test_musical_notes():
txt = "Is ♬ ♫ ♪ ♩ a melody or just noise?"
assert slugify(txt) == "Is-a-melody-or-just-noise"
assert slugify_unicode(txt) == "Is-a-melody-or-just-noise"
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list