web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

char Å Ø Æ problem, has made question simple

(0) ShareShare
ReportReport
Posted on by 80

 reader = new System.IO.StreamReader(localFileNameAndPath);

    utf8 = System.Text.Encoding::get_UTF8();

    fileContent = utf8.GetBytes(reader.ReadToEnd());

    reader.Close();

 

From above , I am reading a file and for example my first char is Å    

 

SO, 

    ch = fileContent.GetValue(0);

    print  fileContent.GetValue(0); // wrong value here 

    print num2char(ch);  // strange char.  should be Å

 

    print  char2num('Å',1) // should be this value 

 

 

How can I get the correct value  in  fileContent.GetValue(0)??

I tried UTF8 and other function those are available..

 

If anyone have any clue please help.

 

Thanx

kabir

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    StreamReader expects an UTF-8 content by default. If your file is in a different encoding, you have to specify it in a StreamReader constructor (e.g. new System.IO.StreamReader(file, System.Text.Encoding::GetEncoding(1250))).

    When the StreamReader instance uses the same encoding as the file, you can simply call string s = reader.ReadToEnd().

  • kabir Profile Picture
    80 on at

    I am using simple txt file to read file and  tried many encoding code in System.Text.Encoding::GetEncoding(...)) . Still does not work. If any suggestion ...

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    You simply need to find out the encoding of your file. I would expect 1252, but I can guess only...

  • kabir Profile Picture
    80 on at

    Hi martin,First of all thank you.

    If I save my file utf-8 then it works but if I save it  in ANSI it does not work.

    All of my file automatically generated in ANSI. So I have to read it  in ANSI. ??

     

    Thank you

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans