none
Encoding Format Issue in .net core RRS feed

  • Question

  • I want to Encode a file , i have already write some code for that but i think it's not working properly. Code like this actually I am doing to convert a csv file and i am select encoding format on database through drop down list after selecting a encoding format like ISO-8859-1 or Windows-1252 and download the data file .after downloaded data file open in notepad and see that file it will not to be selected encoding format

    case "ISO-8859-1":
        File.WriteAllBytes(fileName, ASCIIEncoding.Convert(
                                            ASCIIEncoding.ASCII, 
                                            Encoding.GetEncoding("ISO-8859-1"), 
                                            convertToCSV(queryExecutionResult, fileName)));
        break;
    case "Windows-1252":
        File.WriteAllBytes(fileName, ASCIIEncoding.Convert(
                                             ASCIIEncoding.ASCII, 
                                             Encoding.GetEncoding(1252), 
                                             convertToCSV(queryExecutionResult, fileName)));
        break;

    Thursday, September 12, 2019 6:30 AM

All replies

  • Does it work using this approach?

       File.WriteAllText( fileName,

                       convertToCSV( queryExecutionResult, fileName),

                       Encoding.GetEncoding( 1252));

    Thursday, September 12, 2019 6:48 AM
  • Not work . Conversation Issue

    Thursday, September 12, 2019 8:56 AM
  • Hello Jadhav A,

    This forum is for "Discuss general issues about developing applications for Windows."

    Since your issue is .NET related I'll move it to C# forum for more professional support.

    Best regards,

    Rita


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 13, 2019 1:31 AM
  • I think notepad will only detect UTF16LE/UTF16BE/UTF8 with Byte-Order-Mark(BOM). For other code pages text file lacks method to tell what code pages the file is currently in, and will be treated as ASCII and subject to your "Language for non-Unicode programs" settings.

    As long as you try to open the file with IE, selecting the code page you are expecting, and the file does display correctly, you ought to be okay.

    Friday, September 13, 2019 3:55 AM
    Answerer