ctolkien / Slugify

Simple Slug / Clean URL generator helper for Microsoft .NET framework / .NET Standard.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Persian encoding

bshafiei-ir opened this issue · comments

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

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?

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

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

commented

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

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?

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.

Please see #82 for feedback.

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