TStringList.loadfromfile not loading special chars [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • LoadFromFile with Unicode data

    2 answers




I'm using Delphi XE to load a txt file into a TStringList. Problem is, all special chars on my file are being loaded corrupted. My code is simple as :



sl := tstringlist.create;
sl.loadfromfile('c:myfile.txt');


Here are the contents of 'myfile.txt' :



João Pessoa


After loaded to stringlist, it becames



João Pessoa


How can i fix this ?



Thanks !










share|improve this question













marked as duplicate by David Heffernan delphi
Users with the  delphi badge can single-handedly close delphi questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 8 at 12:54


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















    up vote
    0
    down vote

    favorite













    This question already has an answer here:




    • LoadFromFile with Unicode data

      2 answers




    I'm using Delphi XE to load a txt file into a TStringList. Problem is, all special chars on my file are being loaded corrupted. My code is simple as :



    sl := tstringlist.create;
    sl.loadfromfile('c:myfile.txt');


    Here are the contents of 'myfile.txt' :



    João Pessoa


    After loaded to stringlist, it becames



    João Pessoa


    How can i fix this ?



    Thanks !










    share|improve this question













    marked as duplicate by David Heffernan delphi
    Users with the  delphi badge can single-handedly close delphi questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 8 at 12:54


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:




      • LoadFromFile with Unicode data

        2 answers




      I'm using Delphi XE to load a txt file into a TStringList. Problem is, all special chars on my file are being loaded corrupted. My code is simple as :



      sl := tstringlist.create;
      sl.loadfromfile('c:myfile.txt');


      Here are the contents of 'myfile.txt' :



      João Pessoa


      After loaded to stringlist, it becames



      João Pessoa


      How can i fix this ?



      Thanks !










      share|improve this question














      This question already has an answer here:




      • LoadFromFile with Unicode data

        2 answers




      I'm using Delphi XE to load a txt file into a TStringList. Problem is, all special chars on my file are being loaded corrupted. My code is simple as :



      sl := tstringlist.create;
      sl.loadfromfile('c:myfile.txt');


      Here are the contents of 'myfile.txt' :



      João Pessoa


      After loaded to stringlist, it becames



      João Pessoa


      How can i fix this ?



      Thanks !





      This question already has an answer here:




      • LoadFromFile with Unicode data

        2 answers








      delphi delphi-xe






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 8 at 11:17









      delphirules

      1,96992549




      1,96992549




      marked as duplicate by David Heffernan delphi
      Users with the  delphi badge can single-handedly close delphi questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 8 at 12:54


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by David Heffernan delphi
      Users with the  delphi badge can single-handedly close delphi questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 8 at 12:54


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I could solve this issue by replacing this line



          sl.loadfromfile('c:myfile.txt');


          by this :



          sl.loadfromfile('c:myfile.txt',TEncoding.UTF8);


          After that all special chars are loaded correctly.






          share|improve this answer





















          • Yes, if you know that the file uses UTF-8, this is the way to do it.
            – Andreas Rejbrand
            Nov 8 at 11:46


















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          I could solve this issue by replacing this line



          sl.loadfromfile('c:myfile.txt');


          by this :



          sl.loadfromfile('c:myfile.txt',TEncoding.UTF8);


          After that all special chars are loaded correctly.






          share|improve this answer





















          • Yes, if you know that the file uses UTF-8, this is the way to do it.
            – Andreas Rejbrand
            Nov 8 at 11:46















          up vote
          0
          down vote













          I could solve this issue by replacing this line



          sl.loadfromfile('c:myfile.txt');


          by this :



          sl.loadfromfile('c:myfile.txt',TEncoding.UTF8);


          After that all special chars are loaded correctly.






          share|improve this answer





















          • Yes, if you know that the file uses UTF-8, this is the way to do it.
            – Andreas Rejbrand
            Nov 8 at 11:46













          up vote
          0
          down vote










          up vote
          0
          down vote









          I could solve this issue by replacing this line



          sl.loadfromfile('c:myfile.txt');


          by this :



          sl.loadfromfile('c:myfile.txt',TEncoding.UTF8);


          After that all special chars are loaded correctly.






          share|improve this answer












          I could solve this issue by replacing this line



          sl.loadfromfile('c:myfile.txt');


          by this :



          sl.loadfromfile('c:myfile.txt',TEncoding.UTF8);


          After that all special chars are loaded correctly.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 8 at 11:42









          delphirules

          1,96992549




          1,96992549












          • Yes, if you know that the file uses UTF-8, this is the way to do it.
            – Andreas Rejbrand
            Nov 8 at 11:46


















          • Yes, if you know that the file uses UTF-8, this is the way to do it.
            – Andreas Rejbrand
            Nov 8 at 11:46
















          Yes, if you know that the file uses UTF-8, this is the way to do it.
          – Andreas Rejbrand
          Nov 8 at 11:46




          Yes, if you know that the file uses UTF-8, this is the way to do it.
          – Andreas Rejbrand
          Nov 8 at 11:46



          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)