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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to get encoding value in stream

(1) ShareShare
ReportReport
Posted on by 230
Hi Team
Using below link i have generated the .txt file.
 
Below code will store the stream value.
stream = io.getStream();
Below code will store the encoding value.
 
System.Text.Encoding encoding = System.Text.Encoding::get_UTF8()
Now from here i am calling BankStatementImportUtils class for generate the URL.
// For create the URLBankStatementImportUtils::sendFileToTempStore 
sendFileToTempStore method is passing only stream value and file name, i have to pass encoding value also.
 
Please let me know how to pass encoding value.
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,058 Most Valuable Professional on at
    How to get encoding value in stream in D365FO
    sendFileToTempStore() doesn't accepting any Encoding object, therefore passing it there is impossible. You'll need to design a different solution.
     
    Why do you want to do such a thing?
     
    If your goal is generating text with a particular encoding, it's too late - the content was already generated and stored in the stream. You can set encoding (as a code page identifier, not an Encoding object) as a parameter of TextStreamIo::constructForWrite(). The method creates an Encoding object from the code page ID (by calling Encoding::GetEncoding()). The default value is 1200 (UTF-16LE); UTF-8 is 65001.
  • CU21091228-0 Profile Picture
    230 on at
    How to get encoding value in stream in D365FO
    Hi Martin
    Is below code correct?
    io = TextStreamIo::constructForWrite(Encoding::GetEncoding(65001));
     
     
  • Martin Dráb Profile Picture
    237,058 Most Valuable Professional on at
    How to get encoding value in stream in D365FO
    No, it's not. You should have try to compile your code and you would have the answer immediately, without having to write down such a question and waiting for my reply. It won't even compile.
     
    As I said, it needs to be "a code page identifier, not an Encoding object", such as 65001. GetEncoding() is called inside constructForWrite().
  • CU21091228-0 Profile Picture
    230 on at
    How to get encoding value in stream in D365FO
    Sorry, my mistake.
     
    I need Shift-JIS encoding(932)
     
  • Verified answer
    Martin Dráb Profile Picture
    237,058 Most Valuable Professional on at
    How to get encoding value in stream in D365FO
    Now I'm not sure about the situation. I explained in another thread that Notepad++ simply tries to guess the encoding if the file doesn't contain any identification of encoding, such as Unicode BOM. But you choose the right encoding manually and check the file contents. And it's marked as the verified answer there.

    With this knowledge, do you see any problem with what your code generates?

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 628 Most Valuable Professional

#2
CU05031448-0 Profile Picture

CU05031448-0 578

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 570 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans