How to Convert Codepage 1250 to 852 (middle Europe) to import text

NAVFuchsNAVFuchs Member Posts: 76
Hi,

I want to import text (just once for setup) in NAV 2009 R2 codepage 1250 text. As I understand, I have to convert to codepage 852 to
import it per Dataport.

Does anybody know how to convert it in a correct way. A solution via Notepad++ would be also fine.

Did't geht the right way so far.

Thanks.

Answers

  • SunsetSunset Member Posts: 200
    Don't just take my word for it, test it yourself
  • KowaKowa Member Posts: 918
    edited 2017-08-10
    I have written PowerShell scripts for this. All you need to do is to exchange your required codepage numbers in the script.
    http://www.msdynamics.de/viewtopic.php?f=17&t=25726
    In your case it would look like this:
    Function Convert_ANSI1250_OEM852
                {
                $args = resolve-path $args
                $WorkingFolder = Split-Path -Parent $args
                $sourceEncoding = [System.Text.Encoding]::GetEncoding(1250)
                $targetEncoding = [System.Text.Encoding]::GetEncoding(852)
               
                $convertedFileName = [System.IO.Path]::GetFileNameWithoutExtension($args) +"_OEM852" + [System.IO.Path]::GetExtension($args)
                $convertedfile = New-Item -path "$WorkingFolder\$convertedFileName" -type file
               
                $textfile = [System.IO.File]::ReadAllText($args, $sourceencoding)
                [System.IO.File]::WriteAllText($convertedfile, $textfile, $targetencoding)
                Write-host $args 'converted to' $convertedFileName
                }
    

    Call the function together with the path to your source file, the converted one will be written to the same folder.

    Keep in mind that further processing into NAV requires your OS regional settings to have a country in middle europe that uses these codepages (like PL, CZ, etc.) as well for the special characters to look right (also for the Windows editor, in Notepad++ you can change the codepage encoding settings to check the result visually beforehand).
    Kai Kowalewski
  • krikikriki Member, Moderator Posts: 9,094
    I think I used this one in the past : https://mibuso.com/downloads/ansi-ascii-converter.

    I also found another one : https://mibuso.com/downloads/convertasciitoansi-fob-example

    All nicely inside C/AL without .exe, .dll, or PoSh.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • KowaKowa Member Posts: 918
    edited 2017-08-14
    Keep in mind that most ANSI2ASCII-tools were made from the viewpoint of codepages in Western Europe.

    Western Europe, Skandinavia, also Estonia
    ANSI = Codepage 1252
    ASCII = Codepage 850
    In Central/Eastern Europe (without Baltic States)
    ANSI = Codepage 1250
    ASCII = Codepage 852
    Baltic States
    ANSI = Codepage 1257
    ASCII = Codepage 775

    That's why I created these scripts. You can easily adjust them for all purposes.
    Kai Kowalewski
Sign In or Register to comment.