No unicode characters in postprocessor

No unicode characters in postprocessor

pawelzwronek
Advocate Advocate
1,084 Views
6 Replies
Message 1 of 7

No unicode characters in postprocessor

pawelzwronek
Advocate
Advocate

Hi.

When I name the operation e.g. "kupa łąćź ćłżc" or write this text as a comment to 'Manual NC' I get something like this "(kupa1 ӹ柠泿c )" or this "kupa1 Bz B|c)" in my g-code file. Executing setCodePage("UTF-8"); or setCodePage("utf-8"); at the beginning of the postprocessor is not helping 😞

Writing to file writeln("kupa łąćź ćłżc") works fine.

0 Likes
1,085 Views
6 Replies
Replies (6)
Message 2 of 7

fonsecr
Alumni
Alumni

Hi @pawelzwronek

 

Please note that CNCs will commonly not support UTF-8 in the NC programs.

 

I tested that UTF-8 output works fine. So you have to make sure that you dont set the codepage in multiple places.

 

If you edit the dump.cps and add this line then it works for me:

extension = "dmp";
// using user code page
setCodePage("utf-8"); // ADDED THIS LINE FOR UTF-8

capabilities = CAPABILITY_INTERMEDIATE;

allowMachineChangeOnSection = true;

In the output you will then see something like this - see the last onComment():

524: onLinear(-13.815099716186523, 0.4000000059604645, 0, 1000)
525: onMovement(MOVEMENT_RAPID /*rapid*/)
525: onRapid(-13.815099716186523, 0.4000000059604645, 17)
526: onSectionEnd()
  STATE position=[-13.8151, 0.4, 17]
  STATE spindleSpeed=5000
  STATE radiusCompensation=RADIUS_COMPENSATION_OFF // off
528: onComment('kupa łąćź ćłżc ÆØÅæøå')
528: onClose()

René Fonseca
Software Architect

0 Likes
Message 3 of 7

fonsecr
Alumni
Alumni

Make sure you use an editor that supports UTF-8 also and make sure UTF-8 mode is active. Otherwise you will see wrong characters.

 

Also , please note that depending on the post you use it might filter non ASCII characters. These posts will commonly have a variable called permittedCommentChars - that hold the chars that comments will output.


René Fonseca
Software Architect

0 Likes
Message 4 of 7

pawelzwronek
Advocate
Advocate

My modified dump.cps:

...
extension = "dmp";
// using user code page
setCodePage("utf-8");
...
function onComment() {
  dump("onComment kupa łąćź ćłżc", arguments);
  writeln("kupa2 łąćź ćłżc");
}
...

After postprocess of

kupa.png

I get in 1001.dmp this:

...
36: onParameter('operation-strategy', 'contour2d')
37: onParameter('operation-comment', 'kupa łąćź ćłżc')
38: onParameter('autodeskcam:operation-id', 2)
39: onParameter('leads-supported', 1)
40: onParameter('autodeskcam:path', 'Setup1\kupa łąćź ćłżc')
41: onParameter('operation:advancedMode', 0)
...
432: onComment kupa łąćź ćłżc('kupa Bz B|c')
kupa2 łąćź ćłżc
432: onClose()
...

Screen from Notepad++:

kupa++.png

 

So operation names are fine but dont know why but comments and writeln hardcoded unicode text are wrong.

0 Likes
Message 5 of 7

pawelzwronek
Advocate
Advocate

With disabled 'utf-8' in dump.cps I get:

...
37: onParameter('operation-comment', 'kupa ӹ柠泿c')
38: onParameter('autodeskcam:operation-id', 2)
39: onParameter('leads-supported', 1)
40: onParameter('autodeskcam:path', 'Setup1\kupa ӹ柠泿c')
41: onParameter('operation:advancedMode', 0)
...
432: onComment kupa łąćź ćłżc('kupa Bz B|c')
kupa2 łąćź ćłżc
432: onClose()
...

 

0 Likes
Message 6 of 7

fonsecr
Alumni
Alumni

Are you on Windows or Mac? Should behave the same but good to know when I'll check this later.

 

I cant see which encoding you used for the cps edits. But I'll check if UTF-8 works properly also.

 


René Fonseca
Software Architect

0 Likes
Message 7 of 7

pawelzwronek
Advocate
Advocate

I'm on Windows10/64bit and dump.cps also in utf-8.

0 Likes