温馨提示:本文翻译自stackoverflow.com,查看原文请点击:x++ - Save text file with code page UTF-8 in Axapta 3.0
axapta x++

x++ - 在Axapta 3.0中使用代码页UTF-8保存文本文件

发布于 2020-04-21 12:35:50

如何在Axapta 3.0中使用代码页UTF-8制作文本文件?

我不能使用

myFile = new CommaIo(myFileName, 'W', 65001);

就像我们在较新版本的Axapta中一样。在Axapta 3.0中,new CommaIo只有前两个参数。

查看更多

提问者
Morten
被浏览
20
Alex Kwitny 2020-02-06 00:50

我尚未在3.0中工作,但我为您提供了一些想法,可能会为您提供正确的方法。

1)你有CommaTextIo还是TextIo这些是您可以在其中指定代码页的对象。

2)在中AOT查看并查看是否有一个名为的宏#File,在内部查看是否具有#utf8Format(65001),请使用X-Ref(或Ctrl + F)在系统中查找使用该宏的其他位置。然后,您可以看到他们可能会如何完成UTF-8

3)查看是否可以CommaIo与某些.NET代码结合使用,还是仅手动生成CSV。也许生成您的CSV并将其写入,然后使用以下方法(从MetadataXMLGenerator作业中)读取并重新写入

void write(str _directory, str _name, str _text)
{
    str path;
    ;

    _text = System.Text.RegularExpressions.Regex::Replace(_text, '\n', '\r\n');
    if (!System.IO.Directory::Exists(_directory))
    {
        System.IO.Directory::CreateDirectory(_directory);
    }
    path = System.IO.Path::Combine(_directory, _name);
    System.IO.File::WriteAllText(path, _text, System.Text.Encoding::get_UTF8());
}