ctolkien / Slugify

Simple Slug / Clean URL generator helper for Microsoft .NET framework / .NET Standard.
MIT License
98 stars 13 forks source link

Persian encoding #9

Open bshafiei-ir opened 6 years ago

bshafiei-ir commented 6 years ago

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

ctolkien commented 6 years ago

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?

bshafiei-ir commented 6 years ago

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

ctolkien commented 1 year ago

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

arisliang commented 1 year ago

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

ctolkien commented 1 year ago

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?

nnhhttmmjjyy commented 1 year ago

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.

ctolkien commented 1 year ago

Please see #82 for feedback.

ctolkien commented 1 year ago

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