Encoding Text für writing a textfile

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Fischer

    Encoding Text für writing a textfile

    Hi everybody,

    i have a problem with teh StreamWriter Object. I want to force the Stream to
    write an ANSI-text. For reading from an filestream i can define the type of
    ASCI by setting
    System.Text.Enc oding.Default.

    What about Wrting Textdate ? The result seems to be UTF7 -Charset, but no
    real ANSI.

    Any hint for me ?

    Martin


  • Peter Duniho

    #2
    Re: =?utf-8?Q?Encoding_Te xt_f=C3=BCr_wri ting_a_textfil? ==?utf-8?Q?e?=

    On Fri, 07 Dec 2007 13:24:05 -0800, Martin Fischer <NOSPAM@nowhere .com>
    wrote:
    Hi everybody,
    >
    i have a problem with teh StreamWriter Object. I want to force the
    Stream to
    write an ANSI-text. For reading from an filestream i can define the type
    of
    ASCI by setting
    System.Text.Enc oding.Default.
    What "type of ASCII"? There's only one ASCII. How do you set
    System.Text.Enc oding.Default, given that it's a read-only property?

    As far as the StreamWriter goes, you can specify an encoding via the
    constructor when you instantiate the StreamWriter.

    Pete

    Comment

    • RobertK

      #3
      =?iso-8859-1?Q?Re:_Encodin g_Text_f=FCr_wr iting_a_textfil e?=

      Do you mean you want the file written in plain ASCII?

      This appears to produce a simple ASCII text file:

      FileStream FS = new FileStream("d:\ \myfile.txt",Fi leMode.OpenOrCr eate);
      StreamWriter SW = new StreamWriter(FS , Encoding.ASCII) ;



      Comment

      • Martin Fischer

        #4
        Re: Encoding Text für writing a textfile

        Thanks a lot. Thats what i ve been searching for ...

        I have been trying to create a StreamWriter-Object without creating a
        previos filestram, and in this structure i didnt find a way to specify the
        Encodeng ....

        Wish you a nice weekend.

        Martin


        "RobertK" <robertk@xmissi on.comschrieb im Newsbeitrag
        news:929BAA78-543E-420C-A0E6-0C9CC33F4CB1@mi crosoft.com...
        Do you mean you want the file written in plain ASCII?
        >
        This appears to produce a simple ASCII text file:
        >
        FileStream FS = new FileStream("d:\ \myfile.txt",Fi leMode.OpenOrCr eate);
        StreamWriter SW = new StreamWriter(FS , Encoding.ASCII) ;
        >
        >
        >

        Comment

        • Peter Duniho

          #5
          Re: =?utf-8?Q?Encoding_Te xt_f=C3=BCr_wri ting_a_textfil? ==?utf-8?Q?e?=

          On Fri, 07 Dec 2007 22:45:10 -0800, Martin Fischer <NOSPAM@nowhere .com>
          wrote:
          I have been trying to create a StreamWriter-Object without creating a
          previos filestram, and in this structure i didnt find a way to specify
          the
          Encodeng ....
          Why there's no StreamWriter(St ring, Encoding) overload, I don't know. But
          there are other overloads for the StreamWriter constructor that take a
          file name and an encoding. For example:



          Pete

          Comment

          Working...