Error: illegal character: ‘\u200b’
编译错误如下
错误原因
此类错误关注这个错误的字符——’\u200b’
'\u200b’表示为zero-width-space,以Unicode编码。因此,你使用的Editor对文件(源文件)的编码方式是UTF-8。
在我使用过程中,我遇到这类错误发生的情况有:
- 在两个UTF-8源文件之间copy,之后进行编译
- 一个UTF-8源文件复制了网页上的内容,比如copy了API文档的内容,之后进行编译
纠正过程
下面给出错误源代码,只需要关注错误行,使用简单点的Editor就可以纠正错误了。
CalcGUI源代码
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import gbc.GBC;
public class CalcGUI
{
private Frame f = new Frame("Calculator");
private TextField text = new TextField("0");
private final String[] btStrs = {
"MC", "MR", "MS", "M+", "M-", "←", "CE",
"C", "±", "√", "7", "8", "9", "/", "%", "4", "5", "6", "*",
"1/x", "1", "2", "3", "-", "=", "0", ".", "+"};
private Button[] bts = new Button[28];
private Panel p1 = new Panel();
private GridBagLayout gbl = new GridBagLayout();
private boolean firstNumPhrase = false;
private boolean secondNumPhrase = false;
private String firstNum = "";