Slugify y transliteración de caracteres en C #
Estoy tratando de traducir el siguiente método slugify de PHP a C #:http://snipplr.com/view/22741/slugify-a-string-in-php/
Editar: Por conveniencia, aquí el código de arriba:
/**
* Modifies a string to remove al non ASCII characters and spaces.
*/
static public function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
// transliterate
if (function_exists('iconv'))
{
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
}
// lowercase
$text = strtolower($text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text))
{
return 'n-a';
}
return $text;
}
No tuve problemas para codificar el resto, excepto que no puedo encontrar el equivalente de C # de la siguiente línea de código PHP:
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
Editar: El propósito de esto es traducir caracteres no ASCII comoReformáció Genfi Emlékműve Előtt
dentroreformacio-genfi-emlekmuve-elott