error: stray '\302' in program

后端 未结 8 1106
谎友^
谎友^ 2021-01-17 16:11

I\'m using Code::Blocks on Ubuntu 10.10. I have connected a Mac keyboard and set the keyboard settings to \"Swiss German Mac\". Now whenever I write an equals sign, followed

相关标签:
8条回答
  • 2021-01-17 16:41

    I have seen this type of issue when copying and pasting from web pages or other electronic documents. The common culprits would be invalid quotes like ` instead of ', or something alike. Try to use the compiler error to guide you into where in the file the error might be.

    0 讨论(0)
  • 2021-01-17 16:42

    Since you're sure it's caused by hitting shift+space, you can check what X itself is doing by. First, run xev from the command line, hit shift+space and check the output. For example, I see:

    $ xev
    KeyPress event, serial 29, synthetic NO, window 0x2000001,
        root 0x3a, subw 0x0, time 4114211795, (-576,-249), root:(414,593),
        state 0x0, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
        XLookupString gives 0 bytes:
        XmbLookupString gives 0 bytes:
        XFilterEvent returns: False
    
    KeyPress event, serial 29, synthetic NO, window 0x2000001,
        root 0x3a, subw 0x0, time 4114213059, (-576,-249), root:(414,593),
        state 0x1, keycode 65 (keysym 0x20, space), same_screen YES,
        XLookupString gives 1 bytes: (20) " "
        XmbLookupString gives 1 bytes: (20) " "
        XFilterEvent returns: False
    ...
    

    Then, run xmodmap -pk and look up the keycode (space should be 65 as above, but check your xev output). If you see something like

         65         0x0020 (space)
    

    Then X isn't doing this. On the other hand, if I pick a character key which is modified by shift, I see something like this:

         58         0x006d (m)      0x004d (M)
    

    If you have two or more keysyms for your keycode, X is the culprit. In that case, something like xmodmap -e 'keycode 65 space' should work.

    0 讨论(0)
  • 2021-01-17 16:45

    '\302' is C notation for the octal number 3028, which equals C216 and 19410. So it's not ASCII.

    Which character it maps to depends on the encoding. In Latin-1, it's the  character, for instance.

    0 讨论(0)
  • 2021-01-17 16:46

    I've seen this problem in my linux box with finnish keyboard. Also happens with emacs etc. I don't have good solution for it, but guess reports about the fact that it happens elsewhere are also useful...

    0 讨论(0)
  • 2021-01-17 16:48

    \302 stands for the octal representation of byte value the compiler encountered. It translates to 11000010 in binary, which makes me think it's the start of a two byte utf-8 sequence. Then this sequence must be:

    11000010 10??????
    

    Which encodes the binary unicode point 10??????, which can be anything from U+80 to U+BF.

    Several characters starting from U+80 are special spaces and breaks which usually are not shown inside a text editor.

    Probably it's not your editor but Xorg, that emits these characters due to your keyboard settings. Try switching to a generic US keyboard and test if the problems persists.

    0 讨论(0)
  • 2021-01-17 16:57

    That sounds like some kind of encoding issue. I haven't used code::blocks for years, so not sure if it allows you to pick different encodings. How about opening your code file with gedit and saving it as UTF-8, then try again? But sounds rather strange that you get such an issue using space characters.

    0 讨论(0)
提交回复
热议问题