IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

lecture du langue arabe du fichier .docx


Sujet :

C#

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 59
    Points : 33
    Points
    33
    Par défaut lecture du langue arabe du fichier .docx
    bonjour tout le monde

    j'ai une application c# qui permet la lecture des fichier dans un textbox.
    la lectures du contenu des fichier ecrite en langue français se fait avec succès mais en langue arabe j'obtient un affichage comme ça????????
    voila mon code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
     
     try
                    {
                        OpenFileDialog path = new OpenFileDialog();
                        //making an object for the OpenFileDialog
                        path.Title = "Tauqeer Sample";
                        path.InitialDirectory = @"c:\";
                        path.RestoreDirectory = true;
     
                        if (path.ShowDialog() == DialogResult.OK)
                        {
                            textBox1.Text = path.FileName.ToString();
                            source = path.FileName.ToString();
                        }
                    }
                    catch (Exception l)
                    {
                        MessageBox.Show(l.Message);
                    }
                    //*****************************************************
                    try
                    {
                        
                        // Microsoft.Office.Interop.
                        Microsoft.Office.Interop.Word.Application wordObject = new Microsoft.Office.Interop.Word.Application();
                        object file = textBox1.Text; //this is the path
                        object nullobject = System.Reflection.Missing.Value;
                        Microsoft.Office.Interop.Word.Document docs = wordObject.Documents.Open
                            (ref file, ref nullobject, ref nullobject, ref nullobject,
                            ref nullobject, ref nullobject, ref nullobject, ref nullobject,
                            ref nullobject, ref nullobject, ref nullobject, ref nullobject,
                            ref nullobject, ref nullobject, ref nullobject, ref nullobject
                                            );
                        docs.ActiveWindow.Selection.WholeStory();
                        docs.ActiveWindow.Selection.Copy();
                        IDataObject data = Clipboard.GetDataObject();
                        textBox1.Text = data.GetData(DataFormats.Text).ToString();
                        docs.Close(ref nullobject, ref nullobject, ref nullobject);
                    }
                    catch (Exception j)
                    {
                        MessageBox.Show(j.Message);
                    }
                }
    est ce qu'il ya une solution pour ajouter un "Encoding.default ou utf8" pour avoir la possibilité de lecture de langue arabe et français

    Merci pour votre aide.

  2. #2
    Membre éprouvé Avatar de sisqo60
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Février 2006
    Messages
    754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 754
    Points : 1 188
    Points
    1 188
    Par défaut
    Bonjour,

    regardes ce lien

    Bon dév.

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 59
    Points : 33
    Points
    33
    Par défaut
    Citation Envoyé par sisqo60 Voir le message
    Bonjour,

    regardes ce lien

    Bon dév.
    Bonjour

    j'ai essaye avec le lien mais l'affichage reste "??????????" avec la langue arabe
    est ce que tu peut m'aider a amélioré mon code pour qu'il permet la lecture du langue française et arabe ??

    Merci

  4. #4
    Membre éprouvé Avatar de sisqo60
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Février 2006
    Messages
    754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 754
    Points : 1 188
    Points
    1 188
    Par défaut
    Oui...

    Ma réponse est toute aussi pertinente que ta question!!!

    Plus sérieusement pour qu'on t'aide, il va falloir nous poster du code...

  5. #5
    Membre à l'essai
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Juillet 2011
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Mauritanie

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2011
    Messages : 11
    Points : 24
    Points
    24
    Par défaut
    Citation Envoyé par morched89 Voir le message
    bonjour tout le monde

    j'ai une application c# qui permet la lecture des fichier dans un textbox.
    la lectures du contenu des fichier ecrite en langue français se fait avec succès mais en langue arabe j'obtient un affichage comme ça????????
    voila mon code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
     
     try
                    {
                        OpenFileDialog path = new OpenFileDialog();
                        //making an object for the OpenFileDialog
                        path.Title = "Tauqeer Sample";
                        path.InitialDirectory = @"c:\";
                        path.RestoreDirectory = true;
     
                        if (path.ShowDialog() == DialogResult.OK)
                        {
                            textBox1.Text = path.FileName.ToString();
                            source = path.FileName.ToString();
                        }
                    }
                    catch (Exception l)
                    {
                        MessageBox.Show(l.Message);
                    }
                    //*****************************************************
                    try
                    {
                        
                        // Microsoft.Office.Interop.
                        Microsoft.Office.Interop.Word.Application wordObject = new Microsoft.Office.Interop.Word.Application();
                        object file = textBox1.Text; //this is the path
                        object nullobject = System.Reflection.Missing.Value;
                        Microsoft.Office.Interop.Word.Document docs = wordObject.Documents.Open
                            (ref file, ref nullobject, ref nullobject, ref nullobject,
                            ref nullobject, ref nullobject, ref nullobject, ref nullobject,
                            ref nullobject, ref nullobject, ref nullobject, ref nullobject,
                            ref nullobject, ref nullobject, ref nullobject, ref nullobject
                                            );
                        docs.ActiveWindow.Selection.WholeStory();
                        docs.ActiveWindow.Selection.Copy();
                        IDataObject data = Clipboard.GetDataObject();
                        textBox1.Text = data.GetData(DataFormats.Text).ToString();
                        docs.Close(ref nullobject, ref nullobject, ref nullobject);
                    }
                    catch (Exception j)
                    {
                        MessageBox.Show(j.Message);
                    }
                }
    est ce qu'il ya une solution pour ajouter un "Encoding.default ou utf8" pour avoir la possibilité de lecture de langue arabe et français

    Merci pour votre aide.
    le fichier avoir un encodage UTF8 . ça marche chez moi sans problème.

  6. #6
    Membre éprouvé Avatar de sisqo60
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Février 2006
    Messages
    754
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Indre et Loire (Centre)

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Février 2006
    Messages : 754
    Points : 1 188
    Points
    1 188
    Par défaut
    remplaces ta ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    textBox1.Text = data.GetData(DataFormats.Text).ToString();
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    textBox1.Text = ChangeEncoding(data.GetData(DataFormats.Text).ToString(), Encoding.Default, Encoding.UTF8);
    et ajoute toi la fonction suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    private static string ChangeEncoding(string aString, Encoding aSourceEncoding, Encoding aDestinationEncoding)
            {
                if (string.IsNullOrEmpty(aString))
                    return aString;
                if (aSourceEncoding == null)
                    throw new ArgumentNullException("aSourceEncoding");
                if (aDestinationEncoding == null)
                    throw new ArgumentNullException("aDestinationEncoding");
     
                byte[] tmp = aSourceEncoding.GetBytes(aString);
                return aDestinationEncoding.GetString(tmp);
            }
    PS : si encoding UTF8 ne fonctionne pas, cherches le bon encodage source et destination...

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 59
    Points : 33
    Points
    33
    Par défaut
    Citation Envoyé par sisqo60 Voir le message
    remplaces ta ligne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    textBox1.Text = data.GetData(DataFormats.Text).ToString();
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    textBox1.Text = ChangeEncoding(data.GetData(DataFormats.Text).ToString(), Encoding.Default, Encoding.UTF8);
    et ajoute toi la fonction suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    private static string ChangeEncoding(string aString, Encoding aSourceEncoding, Encoding aDestinationEncoding)
            {
                if (string.IsNullOrEmpty(aString))
                    return aString;
                if (aSourceEncoding == null)
                    throw new ArgumentNullException("aSourceEncoding");
                if (aDestinationEncoding == null)
                    throw new ArgumentNullException("aDestinationEncoding");
     
                byte[] tmp = aSourceEncoding.GetBytes(aString);
                return aDestinationEncoding.GetString(tmp);
            }
    PS : si encoding UTF8 ne fonctionne pas, cherches le bon encodage source et destination...
    bonjour
    j'ai changer mon code et j'ai changer différent encoding mais l'affichage reste :"???????????????"

  8. #8
    Membre émérite
    Avatar de azstar
    Homme Profil pro
    Architecte Technique BizTalk/.NET
    Inscrit en
    Juillet 2008
    Messages
    1 198
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Architecte Technique BizTalk/.NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2008
    Messages : 1 198
    Points : 2 424
    Points
    2 424
    Par défaut
    a tu déjà verifier que tu n' a pas de probleme dans ton OS côte affichage de langue arabe par exemple ???

    tu travail en quel plateforme je veux dire le système d’exploitation ;et a tu du probleme d'affichage d’arabe dans ton Windows?!!

  9. #9
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Mai 2011
    Messages
    59
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Canada

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2011
    Messages : 59
    Points : 33
    Points
    33
    Par défaut
    Citation Envoyé par azstar Voir le message
    a tu déjà verifier que tu n' a pas de probleme dans ton OS côte affichage de langue arabe par exemple ???

    tu travail en quel plateforme je veux dire le système d’exploitation ;et a tu du probleme d'affichage d’arabe dans ton Windows?!!
    bonjour
    non pas de problème de lecture arabe et mon os est le windows 7
    j'ai essayé une autre petite application qui lit l'arabe mais ele ne donne pas les retour à la ligne et elle ne donne pas l'accées pour la lectures des fichier .txt
    et voila son code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
    StringBuilder builder = new StringBuilder();
                         using (Package package = Package.Open(source, FileMode.Open, FileAccess.ReadWrite))
                         {
                             XmlDocument xmlDoc = new XmlDocument();
                             xmlDoc.Load(package.GetPart(new Uri("/word/document.xml", UriKind.Relative)).GetStream());
                             XmlNamespaceManager mgr = new XmlNamespaceManager(xmlDoc.NameTable);
                             mgr.AddNamespace("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
     
                             foreach (XmlNode node in xmlDoc.SelectNodes("/descendant::w:p", mgr))  ///descendant::w:t
     
                   {
                       //builder.AppendLine(node.InnerText);
                                 int a=textBox1.SelectionStart;
                       //builder.Insert(a,node.InnerText);
                      builder.Append(node.InnerText);
     
                   }
               }
               textBox1.Text= builder.ToString();
    vous pouver verifier ça

Discussions similaires

  1. javax.mail.Part.getFileName() et nom de fichier en langue arabe
    Par elhaj_hassen dans le forum API standards et tierces
    Réponses: 4
    Dernier message: 15/01/2012, 16h48
  2. Impossible de sauvegarder un fichier dans la langue arabe
    Par maysam dans le forum Eclipse Java
    Réponses: 1
    Dernier message: 04/01/2011, 13h31
  3. Fichier XML qui traite des documents en langue Arabe
    Par samorra dans le forum Format d'échange (XML, JSON...)
    Réponses: 7
    Dernier message: 31/12/2010, 01h41
  4. [Word] Lecture nombre de mots fichier docx
    Par acamentis dans le forum Bibliothèques et frameworks
    Réponses: 6
    Dernier message: 08/09/2008, 10h35
  5. Réponses: 2
    Dernier message: 26/09/2003, 14h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo