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

Composants VCL Delphi Discussion :

[XE2] Afficher le contenu d'un fichier OEM dans un TMemo


Sujet :

Composants VCL Delphi

  1. #1
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut [XE2] Afficher le contenu d'un fichier OEM dans un TMemo
    Bonjour !

    Je voudrais faire un simple éditeur de fichiers de commandes pour Windows, avec Delphi XE2.

    Je voudrais savoir comment on peut afficher correctement dans un TMemo le contenu du fichier qui est au format OEM. Actuellement, le fichier sauvegardé est identique au fichier initial (lorsqu'on exécute le script, les accents s'affichent correctement), mais dans l'éditeur les accents s'affichent mal.

    J'ai essayé l'option OEMConvert mais apparemment ce n'est pas la bonne option.

    Je joins mon projet avec le fichier de commande (créé avec PSPad, menu "Format", option "OEM").
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  2. #2
    Expert éminent sénior
    Avatar de Jipété
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    10 729
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 10 729
    Points : 15 133
    Points
    15 133
    Par défaut
    Salut Roland,

    tu devrais jeter un œil à la fonction OEMtoChar, on en parle ici et là.

    Bon dimanche,
    Il a à vivre sa vie comme ça et il est mûr sur ce mur se creusant la tête : peutêtre qu'il peut être sûr, etc.
    Oui, je milite pour l'orthographe et le respect du trait d'union à l'impératif.
    Après avoir posté, relisez-vous ! Et en cas d'erreur ou d'oubli, il existe un bouton « Modifier », à utiliser sans modération
    On a des lois pour protéger les remboursements aux faiseurs d’argent. On n’en a pas pour empêcher un être humain de mourir de misère.
    Mes 2 cts,
    --
    jp

  3. #3
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Bonjour Jipété !

    Merci pour ta réponse et pour les liens. Ta suggestion serait, si je comprends bien, de lire le contenu du fichier dans une chaîne, de traiter la chaîne puis de remplir le TMemo avec la chaîne (au lieu d'utiliser la méthode LoadFromFile()) ? Et de faire l'opération inverse lors de la sauvegarde ?

    J'ai essayé la chose suivante : rien ne change par rapport au chargement direct avec LoadFromFile(). Est-ce que j'utilise mal la fonction ?

    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
    procedure TForm1.Button1Click(Sender: TObject);
    var
      s: string;
    begin
      if OpenDialog1.Execute then
      begin
        Form1.Caption := OpenDialog1.FileName;
     
        //Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
     
        s := TFile.ReadAllText(OpenDialog1.FileName);
        OEMToChar(@s[1], @s[1]);
        Memo1.Lines.Add(s);
     
        Memo1.SelStart := 0;
      end;
    end;
    Bon dimanche à toi également !
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  4. #4
    Expert éminent sénior
    Avatar de Jipété
    Profil pro
    Inscrit en
    Juillet 2006
    Messages
    10 729
    Détails du profil
    Informations personnelles :
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations forums :
    Inscription : Juillet 2006
    Messages : 10 729
    Points : 15 133
    Points
    15 133
    Par défaut
    À une époque (D7 sous w2k) j'ai utilisé la procédure suivante, appelée comme suit :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    var
      szResult: String;
      slResult: TStringList;
     
    GetConsoleText(Edit1.Text, szResult); // Edit1.Text contient un appel à une commande DOS
    slResult.Text := szResult;
    Memo1.Clear;
    Memo1.Lines := slResult;
    La procédure :
    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    procedure GetConsoleText(const szCommande: String; var szResult: String);
    const
       LENBUFF = 512;
    var
       hReadPipe, hWritePipe: THandle;
       sa: TSecurityAttributes;
       si: TStartupInfo;
       pi: TProcessInformation;
       lpBuffer: Array[0..LENBUFF] of AnsiChar;
       nBytesRead: Cardinal;
       nBytesToRead: Integer;
    begin
       sa.nLength := Sizeof(sa);
       sa.lpSecurityDescriptor := nil;
       sa.bInheritHandle := True;
     
       if not CreatePipe(hReadPipe, hWritePipe, @sa, 0) then
       begin
          Application.MessageBox(PChar('Erreur :  la création du pipe a échoué !' + CRLF
            + SysErrorMessage(GetLastError)), PChar(Application.Title + ' - erreur'), MB_ICONERROR + MB_OK);
          Exit;
       end;
     
       FillChar(si, Sizeof(si), 0);
       si.cb := Sizeof(si);
       si.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;
       si.wShowWindow := SW_HIDE;
       si.hStdInput := 0;
       si.hStdOutput := hWritePipe;
       si.hStdError := hWritePipe;
     
       if not CreateProcess(nil, PChar(szCommande), nil, nil, True, 0, nil, nil, si, pi) then
       begin
          Application.MessageBox(PChar('Erreur :  l''exécution de la commande a échoué !' + CRLF
            + SysErrorMessage(GetLastError)), PChar(Application.Title + ' - erreur'), MB_ICONERROR + MB_OK);
          CloseHandle(hReadPipe);
          CloseHandle(hWritePipe);
          Exit;
       end;
     
       CloseHandle(hWritePipe);
       nBytesToRead := LENBUFF;
       nBytesRead := 0;
     
       szResult := '';      
       while True do
       begin
          lpBuffer := '';
          ReadFile(hReadPipe, lpBuffer, nBytesToRead, nBytesRead, nil);
          if nBytesRead = 0 then
             Break;
          OemToChar(lpBuffer, lpBuffer);
          szResult := szResult + String(lpBuffer);
       end;
     
       WaitForSingleObject(pi.hProcess, INFINITE);
       CloseHandle(pi.hProcess);
       CloseHandle(hReadPipe);
    end;
    Il a à vivre sa vie comme ça et il est mûr sur ce mur se creusant la tête : peutêtre qu'il peut être sûr, etc.
    Oui, je milite pour l'orthographe et le respect du trait d'union à l'impératif.
    Après avoir posté, relisez-vous ! Et en cas d'erreur ou d'oubli, il existe un bouton « Modifier », à utiliser sans modération
    On a des lois pour protéger les remboursements aux faiseurs d’argent. On n’en a pas pour empêcher un être humain de mourir de misère.
    Mes 2 cts,
    --
    jp

  5. #5
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Intéressant, ton exemple. Je m'en vais de ce pas l'essayer avec Delphi 7.

    P.-S. Avec Delphi 7, le résultat d'une commande système s'affiche correctement.

    Avec XE2, cette ligne ne passe pas :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
       szResult := '';      
       while True do
       begin
          lpBuffer := '';
          ReadFile(hReadPipe, lpBuffer, nBytesToRead, nBytesRead, nil);
          if nBytesRead = 0 then
             Break;
          OemToChar(lpBuffer, lpBuffer); // [DCC Erreur] Unit1.pas(78): E2010 Types incompatibles : 'PWideChar' et 'array[0..512] of AnsiChar'
          szResult := szResult + String(lpBuffer);
       end;
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  6. #6
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    J'ai essayé diverses choses pour obtenir le résultat voulu, sans tomber sur la bonne.

    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
    procedure TForm1.Button1Click(Sender: TObject);
    var
      s: string;
      //s: ansistring;
      //e: TEncoding;
    begin
      if OpenDialog1.Execute then
      begin
        Form1.Caption := OpenDialog1.FileName;
     
        //Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
     
        s := TFile.ReadAllText(OpenDialog1.FileName);
     
        //e := TEncoding.ASCII;
        //s := TFile.ReadAllText(OpenDialog1.FileName, e);
     
        //OEMToChar(@s[1], @s[1]);
        //OEMToChar(PAnsichar(s), PChar(s));
        OEMToCharBuff(PAnsiChar(s), PWideChar(s), Length(s));
     
        Memo1.Lines.Add(s);
        //Memo1.Lines.Add(string(s));
     
        Memo1.SelStart := 0;
      end;
    end;
    Avec Delphi 7, la fonction oemtochar() résout effectivement le problème mais avec XE2 je n'ai pas trouvé la bonne formule. Peut-être la solution du problème est-elle de continuer mon projet avec D7 ?

    Comment éditer un fichier au format OEM dans un programme Delphi XE2 ?
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  7. #7
    Membre émérite

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2007
    Messages
    3 387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 387
    Points : 2 999
    Points
    2 999
    Par défaut
    Il n'y a pas une version OemToCharA pour traiter comme de l'ANSI ???

  8. #8
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Papy214 Voir le message
    Il n'y a pas une version OemToCharA pour traiter comme de l'ANSI ???
    Merci pour la suggestion. Voici mon essai. Bonne nouvelle, le texte s'affiche correctement dans le TMemo. Mais le fichier sauvegardé n'est pas identique au fichier initial.

    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
    procedure TForm1.Button1Click(Sender: TObject);
    var
      s: string;
      a: ansistring;
    begin
      if OpenDialog1.Execute then
      begin
        Form1.Caption := OpenDialog1.FileName;
        s := TFile.ReadAllText(OpenDialog1.FileName);
        a := ansistring(s);
        OEMToCharA(PAnsiChar(a), PAnsiChar(a));
        s := string(a);
        Memo1.Text := s;
        Memo1.SelStart := 0;
      end;
    end;
     
    procedure TForm1.Button2Click(Sender: TObject);
    var
      s: string;
      a: ansistring;
    begin
      SaveDialog1.FileName := Form1.Caption;
      if SaveDialog1.Execute then
      begin
        s := Memo1.Lines.Text;
        a := ansistring(s);
        CharToOEMA(PAnsiChar(a), PAnsiChar(a));
        s := string(s);
        TFile.WriteAllText(SaveDialog1.FileName, s);
        Form1.Caption := SaveDialog1.FileName;
      end;
    end;
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  9. #9
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    J'ai fini par trouver une formule qui paraît fonctionner.

    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
    procedure TForm1.Button2Click(Sender: TObject);
    var
      s: string;
      a: ansistring;
      e: TEncoding;
    begin
      SaveDialog1.FileName := Form1.Caption;
      if SaveDialog1.Execute then
      begin
        s := Memo1.Lines.Text;
        a := ansistring(s);
        CharToOEMA(PAnsiChar(a), PAnsiChar(a));
        s := string(s);
     
        //e := TEncoding.GetEncoding(437);
        //e := TEncoding.GetEncoding('IBM437');
        e := TEncoding.GetEncoding('IBM850');
     
        TFile.WriteAllText(SaveDialog1.FileName, s, e);
        Form1.Caption := SaveDialog1.FileName;
      end;
    end;
    Curieusement, quand j'ai voulu ajouter, pour la symétrie, la même variable e dans la procédure d'ouverture d'un fichier, ça ne fonctionnait plus.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  10. #10
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    J'ai fait quelque chose d'instructif, pour moi du moins.

    J'ai créé dans PSPad des fichiers de commandes avec le même contenu mais différentes options de format :

    Code batch : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    @echo off
    rem aàâäeéèêëiîïoôöuùûüç
    echo aàâäeéèêëiîïoôöuùûüç
    pause

    Ensuite j'ai ouvert les fichiers un par un dans mon application XE2, la procédure de chargement étant la suivante :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
        s := TFile.ReadAllText(OpenDialog1.FileName);
        Memo1.Text := s;
    J'ai copié à chaque fois une certaine ligne du TMemo dans mon code et j'en ai fait ceci :

    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
    type
      TEncodingSample = record
        sample,
        codename: string;
      end;
     
    const
      SAMPLE: array[1..5]of TEncodingSample = (
        (sample: 'aàâäeéèêëiîïoôöuùûüç'; codename: 'ANSI'),
        (sample: 'aªâ„e‚‡êëiîƒo“”u–ûç'; codename: 'CP895'),
        (sample: 'aàâäeéèêëiîïoôöuùûüç'; codename: 'ISO 8859-2'),
        (sample: 'a…ƒ„e‚Šˆ‰iŒ‹o“”u—–‡'; codename: 'OEM'),
        (sample: 'aÃ*âäeéèêëiîïoôöuùûüç'; codename: 'UTF-8')
     
      );
    Enfin j'ai ajouté à la fin de la procédure d'ouverture de fichier ce test (qui fonctionne) :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
        for i := 1 to 5 do
          if Pos(SAMPLE[i].sample, Memo1.Lines[2]) > 0 then
            ShowMessage(SAMPLE[i].codename);
    La prochaine étape à laquelle je pensais serait de jouer avec le paramètre TEncoding de ReadAllFile() pour voir ce que ça donne avec les différents fichiers.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  11. #11
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    J'ai fabriqué cette unité pour pouvoir jouer avec le paramètre TEncoding des fonctions ReadAllText() et WriteAllText(). Peut-être cela pourra-t-il intéresser quelqu'un ?

    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
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
     
    (* https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756%28v=vs.85%29.aspx *)
     
    unit CodePageIdentifiers;
     
    interface
     
    type
      TIdentifier = record
        id,
        name,
        info: string;
      end;
     
    const
      IDENTIFIERS: array[1..152] of TIdentifier = (
        (id: '037'; name: 'IBM037'; info: 'IBM EBCDIC US-Canada'),
        (id: '437'; name: 'IBM437'; info: 'OEM United States'),
        (id: '500'; name: 'IBM500'; info: 'IBM EBCDIC International'),
        (id: '708'; name: 'ASMO-708'; info: 'Arabic (ASMO 708)'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '709'; name: ''; info: 'Arabic (ASMO-449+, BCON V4)'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '710'; name: ''; info: 'Arabic - Transparent Arabic'),
        (id: '720'; name: 'DOS-720'; info: 'Arabic (Transparent ASMO); Arabic (DOS)'),
        (id: '737'; name: 'ibm737'; info: 'OEM Greek (formerly 437G); Greek (DOS)'),
        (id: '775'; name: 'ibm775'; info: 'OEM Baltic; Baltic (DOS)'),
        (id: '850'; name: 'ibm850'; info: 'OEM Multilingual Latin 1; Western European (DOS)'),
        (id: '852'; name: 'ibm852'; info: 'OEM Latin 2; Central European (DOS)'),
        (id: '855'; name: 'IBM855'; info: 'OEM Cyrillic (primarily Russian)'),
        (id: '857'; name: 'ibm857'; info: 'OEM Turkish; Turkish (DOS)'),
        (id: '858'; name: 'IBM00858'; info: 'OEM Multilingual Latin 1 + Euro symbol'),
        (id: '860'; name: 'IBM860'; info: 'OEM Portuguese; Portuguese (DOS)'),
        (id: '861'; name: 'ibm861'; info: 'OEM Icelandic; Icelandic (DOS)'),
        (id: '862'; name: 'DOS-862'; info: 'OEM Hebrew; Hebrew (DOS)'),
        (id: '863'; name: 'IBM863'; info: 'OEM French Canadian; French Canadian (DOS)'),
        (id: '864'; name: 'IBM864'; info: 'OEM Arabic; Arabic (864)'),
        (id: '865'; name: 'IBM865'; info: 'OEM Nordic; Nordic (DOS)'),
        (id: '866'; name: 'cp866'; info: 'OEM Russian; Cyrillic (DOS)'),
        (id: '869'; name: 'ibm869'; info: 'OEM Modern Greek; Greek, Modern (DOS)'),
        (id: '870'; name: 'IBM870'; info: 'IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2'),
        (id: '874'; name: 'windows-874'; info: 'ANSI/OEM Thai (ISO 8859-11); Thai (Windows)'),
        (id: '875'; name: 'cp875'; info: 'IBM EBCDIC Greek Modern'),
        (id: '932'; name: 'shift_jis'; info: 'ANSI/OEM Japanese; Japanese (Shift-JIS)'),
        (id: '936'; name: 'gb2312'; info: 'ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312)'),
        (id: '949'; name: 'ks_c_5601-1987'; info: 'ANSI/OEM Korean (Unified Hangul Code)'),
        (id: '950'; name: 'big5'; info: 'ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5)'),
        (id: '1026'; name: 'IBM1026'; info: 'IBM EBCDIC Turkish (Latin 5)'),
        (id: '1047'; name: 'IBM01047'; info: 'IBM EBCDIC Latin 1/Open System'),
        (id: '1140'; name: 'IBM01140'; info: 'IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro)'),
        (id: '1141'; name: 'IBM01141'; info: 'IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro)'),
        (id: '1142'; name: 'IBM01142'; info: 'IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro)'),
        (id: '1143'; name: 'IBM01143'; info: 'IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro)'),
        (id: '1144'; name: 'IBM01144'; info: 'IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro)'),
        (id: '1145'; name: 'IBM01145'; info: 'IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro)'),
        (id: '1146'; name: 'IBM01146'; info: 'IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro)'),
        (id: '1147'; name: 'IBM01147'; info: 'IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro)'),
        (id: '1148'; name: 'IBM01148'; info: 'IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro)'),
        (id: '1149'; name: 'IBM01149'; info: 'IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro)'),
        (id: '1200'; name: 'utf-16'; info: 'Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications'),
        (id: '1201'; name: 'unicodeFFFE'; info: 'Unicode UTF-16, big endian byte order; available only to managed applications'),
        (id: '1250'; name: 'windows-1250'; info: 'ANSI Central European; Central European (Windows)'),
        (id: '1251'; name: 'windows-1251'; info: 'ANSI Cyrillic; Cyrillic (Windows)'),
        (id: '1252'; name: 'windows-1252'; info: 'ANSI Latin 1; Western European (Windows)'),
        (id: '1253'; name: 'windows-1253'; info: 'ANSI Greek; Greek (Windows)'),
        (id: '1254'; name: 'windows-1254'; info: 'ANSI Turkish; Turkish (Windows)'),
        (id: '1255'; name: 'windows-1255'; info: 'ANSI Hebrew; Hebrew (Windows)'),
        (id: '1256'; name: 'windows-1256'; info: 'ANSI Arabic; Arabic (Windows)'),
        (id: '1257'; name: 'windows-1257'; info: 'ANSI Baltic; Baltic (Windows)'),
        (id: '1258'; name: 'windows-1258'; info: 'ANSI/OEM Vietnamese; Vietnamese (Windows)'),
        (id: '1361'; name: 'Johab'; info: 'Korean (Johab)'),
        (id: '10000'; name: 'macintosh'; info: 'MAC Roman; Western European (Mac)'),
        (id: '10001'; name: 'x-mac-japanese'; info: 'Japanese (Mac)'),
        (id: '10002'; name: 'x-mac-chinesetrad'; info: 'MAC Traditional Chinese (Big5); Chinese Traditional (Mac)'),
        (id: '10003'; name: 'x-mac-korean'; info: 'Korean (Mac)'),
        (id: '10004'; name: 'x-mac-arabic'; info: 'Arabic (Mac)'),
        (id: '10005'; name: 'x-mac-hebrew'; info: 'Hebrew (Mac)'),
        (id: '10006'; name: 'x-mac-greek'; info: 'Greek (Mac)'),
        (id: '10007'; name: 'x-mac-cyrillic'; info: 'Cyrillic (Mac)'),
        (id: '10008'; name: 'x-mac-chinesesimp'; info: 'MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac)'),
        (id: '10010'; name: 'x-mac-romanian'; info: 'Romanian (Mac)'),
        (id: '10017'; name: 'x-mac-ukrainian'; info: 'Ukrainian (Mac)'),
        (id: '10021'; name: 'x-mac-thai'; info: 'Thai (Mac)'),
        (id: '10029'; name: 'x-mac-ce'; info: 'MAC Latin 2; Central European (Mac)'),
        (id: '10079'; name: 'x-mac-icelandic'; info: 'Icelandic (Mac)'),
        (id: '10081'; name: 'x-mac-turkish'; info: 'Turkish (Mac)'),
        (id: '10082'; name: 'x-mac-croatian'; info: 'Croatian (Mac)'),
        (id: '12000'; name: 'utf-32'; info: 'Unicode UTF-32, little endian byte order; available only to managed applications'),
        (id: '12001'; name: 'utf-32BE'; info: 'Unicode UTF-32, big endian byte order; available only to managed applications'),
        (id: '20000'; name: 'x-Chinese_CNS'; info: 'CNS Taiwan; Chinese Traditional (CNS)'),
        (id: '20001'; name: 'x-cp20001'; info: 'TCA Taiwan'),
        (id: '20002'; name: 'x_Chinese-Eten'; info: 'Eten Taiwan; Chinese Traditional (Eten)'),
        (id: '20003'; name: 'x-cp20003'; info: 'IBM5550 Taiwan'),
        (id: '20004'; name: 'x-cp20004'; info: 'TeleText Taiwan'),
        (id: '20005'; name: 'x-cp20005'; info: 'Wang Taiwan'),
        (id: '20105'; name: 'x-IA5'; info: 'IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5)'),
        (id: '20106'; name: 'x-IA5-German'; info: 'IA5 German (7-bit)'),
        (id: '20107'; name: 'x-IA5-Swedish'; info: 'IA5 Swedish (7-bit)'),
        (id: '20108'; name: 'x-IA5-Norwegian'; info: 'IA5 Norwegian (7-bit)'),
        (id: '20127'; name: 'us-ascii'; info: 'US-ASCII (7-bit)'),
        (id: '20261'; name: 'x-cp20261'; info: 'T.61'),
        (id: '20269'; name: 'x-cp20269'; info: 'ISO 6937 Non-Spacing Accent'),
        (id: '20273'; name: 'IBM273'; info: 'IBM EBCDIC Germany'),
        (id: '20277'; name: 'IBM277'; info: 'IBM EBCDIC Denmark-Norway'),
        (id: '20278'; name: 'IBM278'; info: 'IBM EBCDIC Finland-Sweden'),
        (id: '20280'; name: 'IBM280'; info: 'IBM EBCDIC Italy'),
        (id: '20284'; name: 'IBM284'; info: 'IBM EBCDIC Latin America-Spain'),
        (id: '20285'; name: 'IBM285'; info: 'IBM EBCDIC United Kingdom'),
        (id: '20290'; name: 'IBM290'; info: 'IBM EBCDIC Japanese Katakana Extended'),
        (id: '20297'; name: 'IBM297'; info: 'IBM EBCDIC France'),
        (id: '20420'; name: 'IBM420'; info: 'IBM EBCDIC Arabic'),
        (id: '20423'; name: 'IBM423'; info: 'IBM EBCDIC Greek'),
        (id: '20424'; name: 'IBM424'; info: 'IBM EBCDIC Hebrew'),
        (id: '20833'; name: 'x-EBCDIC-KoreanExtended'; info: 'IBM EBCDIC Korean Extended'),
        (id: '20838'; name: 'IBM-Thai'; info: 'IBM EBCDIC Thai'),
        (id: '20866'; name: 'koi8-r'; info: 'Russian (KOI8-R); Cyrillic (KOI8-R)'),
        (id: '20871'; name: 'IBM871'; info: 'IBM EBCDIC Icelandic'),
        (id: '20880'; name: 'IBM880'; info: 'IBM EBCDIC Cyrillic Russian'),
        (id: '20905'; name: 'IBM905'; info: 'IBM EBCDIC Turkish'),
        (id: '20924'; name: 'IBM00924'; info: 'IBM EBCDIC Latin 1/Open System (1047 + Euro symbol)'),
        (id: '20932'; name: 'EUC-JP'; info: 'Japanese (JIS 0208-1990 and 0212-1990)'),
        (id: '20936'; name: 'x-cp20936'; info: 'Simplified Chinese (GB2312); Chinese Simplified (GB2312-80)'),
        (id: '20949'; name: 'x-cp20949'; info: 'Korean Wansung'),
        (id: '21025'; name: 'cp1025'; info: 'IBM EBCDIC Cyrillic Serbian-Bulgarian'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '21027'; name: ''; info: '(deprecated)'),
        (id: '21866'; name: 'koi8-u'; info: 'Ukrainian (KOI8-U); Cyrillic (KOI8-U)'),
        (id: '28591'; name: 'iso-8859-1'; info: 'ISO 8859-1 Latin 1; Western European (ISO)'),
        (id: '28592'; name: 'iso-8859-2'; info: 'ISO 8859-2 Central European; Central European (ISO)'),
        (id: '28593'; name: 'iso-8859-3'; info: 'ISO 8859-3 Latin 3'),
        (id: '28594'; name: 'iso-8859-4'; info: 'ISO 8859-4 Baltic'),
        (id: '28595'; name: 'iso-8859-5'; info: 'ISO 8859-5 Cyrillic'),
        (id: '28596'; name: 'iso-8859-6'; info: 'ISO 8859-6 Arabic'),
        (id: '28597'; name: 'iso-8859-7'; info: 'ISO 8859-7 Greek'),
        (id: '28598'; name: 'iso-8859-8'; info: 'ISO 8859-8 Hebrew; Hebrew (ISO-Visual)'),
        (id: '28599'; name: 'iso-8859-9'; info: 'ISO 8859-9 Turkish'),
        (id: '28603'; name: 'iso-8859-13'; info: 'ISO 8859-13 Estonian'),
        (id: '28605'; name: 'iso-8859-15'; info: 'ISO 8859-15 Latin 9'),
        (id: '29001'; name: 'x-Europa'; info: 'Europa 3'),
        (id: '38598'; name: 'iso-8859-8-i'; info: 'ISO 8859-8 Hebrew; Hebrew (ISO-Logical)'),
        (id: '50220'; name: 'iso-2022-jp'; info: 'ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS)'),
        (id: '50221'; name: 'csISO2022JP'; info: 'ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana)'),
        (id: '50222'; name: 'iso-2022-jp'; info: 'ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI)'),
        (id: '50225'; name: 'iso-2022-kr'; info: 'ISO 2022 Korean'),
        (id: '50227'; name: 'x-cp50227'; info: 'ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022)'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50229'; name: ''; info: 'ISO 2022 Traditional Chinese'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50930'; name: ''; info: 'EBCDIC Japanese (Katakana) Extended'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50931'; name: ''; info: 'EBCDIC US-Canada and Japanese'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50933'; name: ''; info: 'EBCDIC Korean Extended and Korean'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50935'; name: ''; info: 'EBCDIC Simplified Chinese Extended and Simplified Chinese'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50936'; name: ''; info: 'EBCDIC Simplified Chinese'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50937'; name: ''; info: 'EBCDIC US-Canada and Traditional Chinese'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '50939'; name: ''; info: 'EBCDIC Japanese (Latin) Extended and Japanese'),
        (id: '51932'; name: 'euc-jp'; info: 'EUC Japanese'),
        (id: '51936'; name: 'EUC-CN'; info: 'EUC Simplified Chinese; Chinese Simplified (EUC)'),
        (id: '51949'; name: 'euc-kr'; info: 'EUC Korean'),
        (* Attention, cette ligne a un nom vide ! *)
        (id: '51950'; name: ''; info: 'EUC Traditional Chinese'),
        (id: '52936'; name: 'hz-gb-2312'; info: 'HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ)'),
        (id: '54936'; name: 'GB18030'; info: 'Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030)'),
        (id: '57002'; name: 'x-iscii-de'; info: 'ISCII Devanagari'),
        (id: '57003'; name: 'x-iscii-be'; info: 'ISCII Bengali'),
        (id: '57004'; name: 'x-iscii-ta'; info: 'ISCII Tamil'),
        (id: '57005'; name: 'x-iscii-te'; info: 'ISCII Telugu'),
        (id: '57006'; name: 'x-iscii-as'; info: 'ISCII Assamese'),
        (id: '57007'; name: 'x-iscii-or'; info: 'ISCII Oriya'),
        (id: '57008'; name: 'x-iscii-ka'; info: 'ISCII Kannada'),
        (id: '57009'; name: 'x-iscii-ma'; info: 'ISCII Malayalam'),
        (id: '57010'; name: 'x-iscii-gu'; info: 'ISCII Gujarati'),
        (id: '57011'; name: 'x-iscii-pa'; info: 'ISCII Punjabi'),
        (id: '65000'; name: 'utf-7'; info: 'Unicode (UTF-7)'),
        (id: '65001'; name: 'utf-8'; info: 'Unicode (UTF-8)')
      );
     
    implementation
     
    end.
    Tout compte fait, il semble que mon problème soit résolu par l'usage correct de ce paramètre, sans utiliser la fonction OEMToChar(), et donc sans avoir besoin de faire des transtypages.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  12. #12
    Membre émérite

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2007
    Messages
    3 387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 387
    Points : 2 999
    Points
    2 999
    Par défaut
    Merci, je prends.

    Par contre, as-tu essayé tous les encodages ?
    J'ai récemment fait le même genre de code pour tester l'encodage d'une chaîne, et certains d'entre eux déclenchaient une erreur au create du TMBCSEncoding.

  13. #13
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Papy214 Voir le message
    Par contre, as-tu essayé tous les encodages ?
    J'ai récemment fait le même genre de code pour tester l'encodage d'une chaîne, et certains d'entre eux déclenchaient une erreur au create du TMBCSEncoding.
    Bon à savoir. Non, je ne les ai pas essayés tous. Je me suis limité à ceux qui semblaient correspondre aux options du menu "Format" de PSPad, soit :

    1. 850, "ibm850", OEM Multilingual Latin 1; Western European (DOS)"
    2. 1252, "windows-1252", "ANSI Latin 1; Western European (Windows)"
    3. 28592, "iso-8859-2", "ISO 8859-2 Central European; Central European (ISO)"
    4. 65001, "utf-8", "Unicode (UTF-8)"
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  14. #14
    Membre émérite

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2007
    Messages
    3 387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 387
    Points : 2 999
    Points
    2 999
    Par défaut
    Codes page récupérés sur le site de crosoft

    TMBCSEncoding.Create(Codes[I])

    709 _ Page de code incorrecte
    710 _ Page de code incorrecte
    1200 _ Page de code incorrecte
    1201 _ Page de code incorrecte
    12000 _ Page de code incorrecte
    12001 _ Page de code incorrecte
    29001 _ Page de code incorrecte
    50930 _ Page de code incorrecte
    50931 _ Page de code incorrecte
    50933 _ Page de code incorrecte
    50935 _ Page de code incorrecte
    50936 _ Page de code incorrecte
    50937 _ Page de code incorrecte
    50939 _ Page de code incorrecte
    51932 _ Page de code incorrecte
    51936 _ Page de code incorrecte
    51950 _ Page de code incorrecte

  15. #15
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Intéressant. Merci pour le partage.

    Pour certaines valeurs de la liste (par exemple 1200), si je regarde les lignes correspondantes dans mon unité, je vois la mention : "available only to managed applications".

    Pour d'autres (par exemple 709), je les avais supprimées parce qu'elles n'avaient pas de nom (voir le document de référence) et que cela me compliquait le travail.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  16. #16
    Membre émérite

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2007
    Messages
    3 387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 387
    Points : 2 999
    Points
    2 999
    Par défaut
    Je n'avais pas fait gaffe à ça. J'ai tout récupéré en bloc, extrait les valeurs numériques, et fait un tableau d'entiers avec le résultat. Je reverrai ma copie à l'occasion.

  17. #17
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Voici la version "finale" de mon éditeur OEM ou éditeur de fichiers de commande Windows.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  18. #18
    Membre émérite

    Homme Profil pro
    Développeur informatique
    Inscrit en
    Novembre 2007
    Messages
    3 387
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 62
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique

    Informations forums :
    Inscription : Novembre 2007
    Messages : 3 387
    Points : 2 999
    Points
    2 999
    Par défaut
    Nom : XE7-1.jpg
Affichages : 576
Taille : 30,7 KoNom : XE7-2.jpg
Affichages : 556
Taille : 30,8 KoNom : XE7-3.jpg
Affichages : 545
Taille : 30,7 KoNom : XE7-4.jpg
Affichages : 568
Taille : 32,8 Ko


    normal ça ??

  19. #19
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Papy214 Voir le message
    normal ça ??
    Merci pour le test.

    C'est le résultat correct (je crois) mais c'est le mode d'emploi du programme qui n'est pas clair. En fait le code page sélectionné dans la ComboBox est utilisé pour la lecture et l'écriture des fichiers. Par défaut c'est le code 850 qui est sélectionné. Donc le résultat n'est bon qu'avec le fichier OEM.cmd (fichier créé avec PSPad, menu "Format", option "OEM"). C'est le résultat attendu.

    Autrement, j'ai passé un coup de chiffon dans le script Lua dont je me suis servi pour fabriquer l'unité. Je le mets aussi en pièce jointe, avec le fichier dont les données sont extraites. J'aime le langage Lua.
    Fichiers attachés Fichiers attachés
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  20. #20
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    J'ai fait encore quelques "découvertes".

    Les méthodes LoadFromFile() et SaveToFile() de l'objet TStrings ont une version surchargée qui permet de passer un paramètre de type TEncoding. Donc pas besoin de passer par une chaîne temporaire comme je l'ai fait :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    procedure TForm1.OpenFile(const aFileName: string);
    var
      //s: string;
      e: TEncoding;
    begin
      Caption := aFileName;
      e := TEncoding.GetEncoding(StrToInt(ComboBox1.Text));
     
      //s := TFile.ReadAllText(aFileName, e);
      //Memo1.Text := s;
      Memo1.Lines.LoadFromFile(aFileName, e);
     
      Memo1.SelStart := 0;
    end;
    J'ai découvert aussi l'existence de la fonction GetOEMCP :

    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
    program GetOEMCodePage;
    {$APPTYPE CONSOLE}
     
    uses
      Windows;
     
    var
      i: integer;
     
    begin
      i := GetOEMCP;
      WriteLn(i); // 850
     
      i := GetACP; // A = ANSI
      WriteLn(i); // 1252
     
      ReadLn;
    end.
    Enfin, j'ai trouvé dans le forum une discussion très instructive, notamment deux messages de ShaiLeTroll qui expliquent la nécessité d'utiliser un éditeur hexadécimal pour ce genre d'exercice, plutôt que Notepad++ par exemple.

    http://www.developpez.net/forums/d11...eres-bizarres/
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Comment afficher le contenu d'un fichier ini dans un mémo?
    Par Jayceblaster dans le forum Langage
    Réponses: 7
    Dernier message: 13/05/2014, 17h38
  2. Afficher le contenu d'un fichier TEXT dans une edit
    Par darkman13130 dans le forum C++Builder
    Réponses: 1
    Dernier message: 06/06/2008, 16h41
  3. Réponses: 4
    Dernier message: 11/07/2007, 18h40
  4. Réponses: 2
    Dernier message: 20/11/2006, 13h55
  5. Afficher le contenu d'un fichier xls dans un DBgrid
    Par bianconeri dans le forum C++Builder
    Réponses: 5
    Dernier message: 03/09/2004, 16h35

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