Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Create a "Standard project" and select CODESYS Control Win V3 as the device.
  • Define the target system by means of the Netzwerksuche Network scan.



  • Open the Library Manager and add the following libraries:
    StringUtils
    SysFile
    SysTypes2 Interfaces



  • Edit the PLC_PRG POU as follows:



    Section


    Column
    width7

    Declaration


    Column
    width93


    Code Block
    themeConfluence
    VAR
        xWrite         : BOOL;
        szFileName     : STRING(128) := 'c:/tmp/TestUTF8.txt';
        hFile          : SysTypes.RTS_IEC_HANDLE := SysTypes.RTS_INVALID_HANDLE;
        iecResult      : SysTypes.RTS_IEC_RESULT;
        wsTextLine     : WSTRING(10) := "Übersetzer";
        sUTF8TextLine  : STRING;
        udiPos         : __XWORD;
        udiWrite       : __XWORD;
    END_VAR






    Section


    Column
    width7

    Implementation


    Code Block
    themeConfluence
    IF xWrite THEN
        xWrite := FALSE;
        hFile := SysFileOpen(szFile:=szFileName, am:=SysFile.AM_Write , pResult:=ADR(iecResult));
        IF hFile <> RTS_INVALID_HANDLE    THEN
            Stu.ConvertUTF16toUTF8(sourceStart := ADR(wsTextLine), targetStart := ADR(sUTF8TextLine), dwTargetBufferSize := SIZEOF(wsTextLine), bStrictConversion := TRUE);
            udiWrite := SysFileWrite(hFile:=hFile, pbyBuffer:=ADR(sUTF8TextLine), ulSize:=INT_TO_UDINT(LEN(sUTF8TextLine)), pResult:=ADR(iecResult));
            iecResult  := SysFileClose(hFile:=hFile);
        END_IF
    END_IF








...