operation on files, replace data in C

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KrisKris
    New Member
    • Oct 2011
    • 5

    operation on files, replace data in C

    Hi,
    I have written a program in C to copy data from input file to output file and is works. Now I want to replace some data from input file before the data will be written to output file. see piece of code bellow
    [CODE]
    if (i == '¿')
    {
    i = ('z');
    }
    else if (i == '³')
    {
    i = ('l');
    }
    else if (i == 'œ')
    {
    i = ('s');
    }
    [/CODE}
    and so on. unfortunately it is not works.
    Do you have any idea why the program do not recognize the strange signs from input text file? I tried change for example a to A or s to 4 and it works perfect.
    or maybe you have other way to replace the strange symbols.
    many thanks for help.
    Kris
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    are those character is ascii table?

    If it is UTF-8 or UNICODE then you will have to change your approach a little

    Comment

    • KrisKris
      New Member
      • Oct 2011
      • 5

      #3
      Hi Johny,
      I not sure about ascii table.
      there are letters from different language then English.
      I have OS in English so when I try to use the text file some characters a displayed as above.
      thanks

      Comment

      • donbock
        Recognized Expert Top Contributor
        • Mar 2008
        • 2427

        #4
        The C Standard says the following in regard to character constants:
        the elements of the sequence [the character(s) within the single quotes] are any members of the source character set; they are mapped in an implementation-defined manner to members of the execution character set
        I suppose there is an incompatibility between how your compiler represents those special characters and how they are represented in the file. Do you any documentation for the text file format?

        Comment

        • KrisKris
          New Member
          • Oct 2011
          • 5

          #5
          Hi donbock,
          Thanks for your reply.
          I do not have any documentations for the text file.
          the file is a subtitles for movie. format .txt
          thanks

          Comment

          Working...