2010-11-10 4 views
3

Salutationsinversion d'une chaîne arabe résultant de ABCpdf .net

j'ai utilisé abcpdf.net pour convertir un pdf arabe par lecture (pdfpath) et les fonctions gettext() ,, le texte donné (chaîne) ressemble à ces il est illisible comme arabe est une langue rtl ,, ma question est maintenant je dois inverser les parties arabes de la chaîne pour le rendre lisible mais je ne sais pas comment puis-je faire cela, donc j'ai besoin d'aide extraire la partie arabe seulement et puis inverser

je suis en utilisant C# et voici un échantillon de la chaîne extraite de mon pdf en utilisant la bibliothèque .NET ABCpdf

0 0,00 KCCUSER1 06:17:19 PM28/10/2010 ةعابطلا خيرات

(200) لوادتملا زكارمو تاكرح

ةصاقملل ةيتيوكلا ةكرشلا

28/10/2010

RBKPI012

لمعلا خيرات

عمجم/ح - 88 لجلا عيبلل افيا ةيلودلا ةيلاملا تاراشتسلا ةكرش - 65646

C023

يحاتتفلا ديصرلا

+1

C'est le travail de l'application qui affiche le texte pour rendre correctement la chaîne. Il doit être conscient de RTL. Vous n'avez pas dit quelle application vous utilisez pour le regarder. –

Répondre

1
private string Convert(string source) 
{ 
    string arabicWord = string.Empty; 
    StringBuilder sbDestination = new StringBuilder(); 

    foreach (var ch in source) 
    { 
     if (IsArabic(ch)) 
      arabicWord += ch; 
     else 
     { 
      if (arabicWord != string.Empty) 
       sbDestination.Append(Reverse(arabicWord)); 

      sbDestination.Append(ch); 
      arabicWord = string.Empty; 
     } 
    } 

    // if the last word was arabic  
    if (arabicWord != string.Empty) 
     sbDestination.Append(Reverse(arabicWord)); 

    return sbDestination.ToString(); 
} 

méthode IsArabic de here

private bool IsArabic(char character) 
{ 
    if (character >= 0x600 && character <= 0x6ff) 
     return true; 

    if (character >= 0x750 && character <= 0x77f) 
     return true; 

    if (character >= 0xfb50 && character <= 0xfc3f) 
     return true; 

    if (character >= 0xfe70 && character <= 0xfefc) 
     return true; 

    return false; 
} 

// Reverse the characters of string 
string Reverse(string source) 
{ 
    return new string(source.ToCharArray().Reverse().ToArray()); 
} 

Bonne chance!