Skip to content

Cannot compile sketch containing invisible characters #1808

Closed as not planned
@kittaakos

Description

@kittaakos

Describe the problem

Sketch compilation fails if the sketch contains invisible characters. I do not know if it's a builder, preprocessor, or pure C++ issue.

To reproduce

void setup() {
  char s = 'x' ;
}
void loop() {}

Note that after the 'x' there is an invisible character.
Screen Shot 2022-07-19 at 11 37 51
Screen Shot 2022-07-19 at 11 37 30

Compilation:

a.kitta@Akoss-MacBook-Pro sketch_jul18b % ~/dev/git/arduino-ide/arduino-ide-extension/build/arduino-cli version
arduino-cli  Version: 0.25.0-rc1 Commit: 63b53c0f Date: 2022-07-11T16:09:52Z
a.kitta@Akoss-MacBook-Pro sketch_jul18b % cat ~/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino 
void setup() {
  char s = 'x' ;
}
void loop() {}
a.kitta@Akoss-MacBook-Pro sketch_jul18b % ~/dev/git/arduino-ide/arduino-ide-extension/build/arduino-cli compile -b arduino:samd:mkr1000 ~/Documents/Arduino/sketch_jul18b 
/Users/a.kitta/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino:2:15: error: stray '\302' in program
   char s = 'x'��;
               ^
/Users/a.kitta/Documents/Arduino/sketch_jul18b/sketch_jul18b.ino:2:16: error: stray '\240' in program
   char s = 'x'��;
                ^



Used platform Version Path                                                                  
arduino:samd  1.8.13  /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/samd/1.8.13

Error during build: exit status 1

Expected behavior

If it's possible to compile a cpp file that contains the <0xa0> invisible character, I would expect to work with the CLI too.

Arduino CLI version

arduino-cli Version: 0.25.0-rc1 Commit: 63b53c0 Date: 2022-07-11T16:09:52Z

Operating system

macOS

Operating system version

12.3.1

Additional context

Based initially on arduino/arduino-ide#1210.
Possibly related (based on the compiler error message): #1785

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    conclusion: invalidIssue/PR not validtopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions