[英]Assign Special Characters inside a String Array
Android 2.3.3 / Java Android 2.3.3 / Java
I have a String[]
that is assigned with static values containing special characters like √x²+y²
and so on. 我有一个
String[]
,它分配有包含特殊字符(如√x²+y²
等)的静态值。 When I try to save the file, i get the following error, please refer to the image below. 当我尝试保存文件时,出现以下错误,请参考下图。 How do I get over this?
我该如何克服? Assigning these values statically is a must.
必须静态分配这些值。 Is there a way I can change the encoding of the java file and yet have other things remain the same.
有没有一种方法可以更改Java文件的编码,但其他参数保持不变。
Here is how I am trying to assign the values ::: For example... 这是我尝试分配值:::例如的方式...
commandNames = new String[] {"√x²+y²","√x²+y²","√x²+y²"};
Your file have utf-8
characters.There is no issue by saving it as Save as UTF-8 您的文件包含
utf-8
字符。 另存为“另存为UTF-8”没有问题
Click that saveasUTF8 button 单击该saveasUTF8按钮
or 要么
Change your file properties by 通过更改文件属性
Windows > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types. Windows>首选项>常规>内容类型,将UTF-8设置为所有内容类型的默认编码。
if you are using this in jsp page then include meta tag in header of your jsp page and specify your content format in meta tag 如果您在jsp页面中使用此标签,则在jsp页面的标题中包含meta标签,并在meta标签中指定您的内容格式
and if it are using it in servlet then set response type as response.setContentType(""); 如果在servlet中使用它,则将响应类型设置为response.setContentType(“”);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.