Slugify icon indicating copy to clipboard operation
Slugify copied to clipboard

Persian encoding

Open bshafiei-ir opened this issue 7 years ago • 8 comments

It doesn't work for Unicode characters such as "نوشتار فارسی". How should I do?

bshafiei-ir avatar Oct 27 '18 08:10 bshafiei-ir

Hi,

Hrm, so this is really supposed to be language agnostic, it will strip diacratic to their base a-z character. I don't really have any idea on how to handle non-latin languages.

Can you advise what a slugged output should be for those characters?

ctolkien avatar Oct 28 '18 21:10 ctolkien

Yes. For example

input; جای مردان سیاست بنشانید درخت تا هوا تازه شود.

output: جای_مردان_سیاست_بنشانید_درخت_تا_هوا_تازه_شود.

I have seen one git project but the main problem is that, it wrote on .net framework 4.6 and has some conflict on .net core 2

bshafiei-ir avatar Oct 29 '18 06:10 bshafiei-ir

This lib has a "known" character set based on the latin alphabet... Not really sure how we could handle this one.

ctolkien avatar Feb 23 '23 02:02 ctolkien

handle in the same way? not the most dynamic way, but it seem to works. another project for ref

arisliang avatar Apr 03 '23 08:04 arisliang

Resurfacing this..... the linked project from @arisliang has a mapping from unicode characters from other languages to an ascii set.

With the source text of: نوشتار فارسی, that would result in nwshtr-frsy

Does that actually solve the issue that people have here?

ctolkien avatar May 09 '23 06:05 ctolkien

As an example, there is another library used on the frontend https://github.com/pid/speakingurl, which also uses character mapping and can be taken as a reference. Character mapping can be found in this file

Input: Наизусть

Output: naizust

A character mapping can be created by comparing the characters in the other libraries to include all common characters.

nnhhttmmjjyy avatar Jul 20 '23 12:07 nnhhttmmjjyy

Please see #82 for feedback.

ctolkien avatar Jul 22 '23 23:07 ctolkien

This is currently in a prerelease v5, you can trial it via:

dotnet add package Slugify.Core --version 5.0.0-prerelease.4

cc @bshafiei-ir , @nnhhttmmjjyy

ctolkien avatar Jul 24 '23 08:07 ctolkien