在Python中,我可以将它转换为Unicode并执行'(?u)^ [\ w] + $'正则表达式搜索,但PHP似乎不了解国际\ w,或者它是什么?
无法在URL中设置包含中文字符的URL连接.它适用于拉丁字符:
String xstr = "???????????" ;
URI uri = new URI("http","ajax.googleapis.com","/ajax/services/language/detect","v=1.0&q="+xstr,null);
URL url = uri.toURL();
URLConnection connection = url.openConnection();
InputStream is = connection.getInputStream() ;
Run Code Online (Sandbox Code Playgroud)
getInputStream()调用导致:
java.lang.IllegalArgumentException: Invalid uri 'http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=???????????': Invalid query
Run Code Online (Sandbox Code Playgroud) 我试图通过exec-maven-plugin执行我的独立应用程序,但是它以WIN编码而不是UTF-8开始。我读到有关Java命令行键-Dfile.encoding = UTF-8的信息。如何将此属性设置为我的应用程序?谢谢
Maven Pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<executable>java</executable>
<mainClass>my.main.Class</mainClass>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud) 我有UTF-8文件,我想用一些HTML标签替换一些2字节的字符.
我想为此制作Python脚本.只需读取文件,char by char,然后输入if等等.
我遇到的问题是,如果我通过char读取char,我正在读取一个字节,但有些字符是1字节,有些是2字节长.
怎么解决?
我基本上需要通过char读取char的功能,但它会知道这个char大小为1或2个字节.
$str使用 成功解密 AES 密码后,我在变量上有一个字符串mcrypt_decrypt。如果我尝试打印str到屏幕,我确实注意到每个字母之间有一个空格,这实际上是NULL termination (\x00)由UTF-16字符编码给出的。
Array
(
[1] => 33
[2] => 0
[3] => 34
[4] => 0
[5] => 35
[6] => 0
...
)
我尝试了很多方法来改变它,UTF-8但都失败了。我能做些什么?
我有包含列及其属性的 MySQL 表:
\n\nname: message\ndatatype: varchar(300)\ndefault/expression: utf8\nRun Code Online (Sandbox Code Playgroud)\n\n我尝试在包含西里尔文文本的表中插入新数据。
\n\n这是我的 sql 查询:
\n\nINSERT INTO db.log (id, info_id, user_id, timestamp, operation, message) \n VALUES ('792','575', '35','2016-12-20 12:09:45','add',\n 'user@gmail.com created new line \xd1\x82\xd0\xb5\xd1\x81\xd1\x82 ')\nRun Code Online (Sandbox Code Playgroud)\n\n我得到了例外:
\n\n1 row(s) affected, 1 warning(s): 1366 Incorrect string value: '\\xD1\\x82\\xD0\\xB5\\xD1\\x81...' for column 'message'
我可以做什么来解决异常?
\n我有一个用atom创建的html文件test.html,其中包含:
\n\n\n\n\n测试\xc3\xa9编码utf-8
\n
当我使用 Powershell 控制台阅读它时(我使用的是法语 Windows)
\n\nGet-Content -Raw test.html\nRun Code Online (Sandbox Code Playgroud)\n\n我得到这个:
\n\nTest\xc3\x83\xc2\xa9 encoding utf-8\nRun Code Online (Sandbox Code Playgroud)\n\n为什么重音字符打印不正确?
\n我刚刚听说 的存在char8_t,char16_t并且char32_t正在测试它。当我尝试编译下面的代码时,g++抛出以下错误:
error: use of deleted function \xe2\x80\x98std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char32_t) [with _Traits = char_traits<char>]\xe2\x80\x99\n 6 | std::cout << U\'\' << std::endl;\n | ^~~~~\nRun Code Online (Sandbox Code Playgroud)\nerror: use of deleted function \xe2\x80\x98std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char32_t) [with _Traits = char_traits<char>]\xe2\x80\x99\n 6 | std::cout << U\'\' << std::endl;\n | ^~~~~\nRun Code Online (Sandbox Code Playgroud)\n另外,为什么我不能将表情符号放入char8_t或char16_t?例如,以下代码行不起作用:
#include <iostream>\n\nint main() {\n char32_t c = U\'\';\n\n std::cout << c << std::endl;\n\n return 0;\n}\n …Run Code Online (Sandbox Code Playgroud) 问题是 openFile 假定 UTF-8 并且句柄返回该编码作为编码。真正的问题是我正在获取(由学生)提交的以 UTF-16LE 编码的文件,我想要识别这些文件,因此我可以将它们转换为 UTF-8。这些文件实际上没有任何超出 ASCII 范围的内容,除了 BOM 标记(转换为 UTF-8 后会排序)。我尝试了以下方法:
fixFileEncoding fname =
do hdl <- openFile fname ReadMode
menc <- hGetEncoding hdl
hClose hdl
case menc of
Nothing -> system ("cp "++fname++" safe"++fname)
Just enc ->
do let encstr = show enc
putStrLn ("@@@@@@" ++ fname ++ " is "++encstr)
if take 6 encstr == "UTF-16"
then
system ("iconv -f UTF-16LE -t UTF-8 "++fname++" > safe"++fname)
else
system ("cp "++fname++" safe"++fname)
Run Code Online (Sandbox Code Playgroud)
无论文件的实际编码如何,“@@@@@”行都会报告 UTF-8。我通过使用 unixfile …
我正在开发一个用于学习目的的Windows游戏(我正在学习DirectX).我希望它有UTF支持.
阅读这个问题我了解到windows使用的wchar_t是UTF-16.我希望我的游戏能够获得Lua脚本支持,而Lua并不太喜欢Unicode.它只是将字符串视为"字节流"; 这对UTF-8来说效果不错,但UTF-16几乎不可能使用.
长话短说:windows想要UTF-16,lua想要UTF-8.
所以我想,我们只是使用UTF-8与正常char*和string!.length()会搞砸但是谁在乎呢?但它不起作用:
const char test_utf8[] = { 111, 108, 0xc3, 0xa9, 0 }; // UTF-8 for olè
mFont->DrawTextA(0, test_utf8, -1, &R, DT_NOCLIP, BLACK);
/* DrawText is a Direct3d function to, well, draw text.
* It's like MessageBox: it is a define to either DrawTextA
* or DrawTextW, depending if unicode is defined or not. Here
* we will use DrawTextA, since we are passing a normal …Run Code Online (Sandbox Code Playgroud)