草庐IT

church-encoding

全部标签

php - 错误 : "Input is not proper UTF-8, indicate encoding !" using PHP's simplexml_load_string

我收到了错误:parsererror:InputisnotproperUTF-8,indicateencoding!Bytes:0xED0x6E0x2C0x20尝试使用simplexml_load_string处理XML响应时来自第3方来源。原始XML响应确实声明了内容类型:然而,XML似乎并不是真正的UTF-8。XML内容的语言是西类牙语,并且包含像Dublín这样的词。在XML中。我无法让第3方整理他们的XML。如何预处理XML并修复编码不兼容问题?有没有办法检测XML文件的正确编码? 最佳答案 您的0xED0x6E0x2C0x

java - Java 中的 "unmappable character for encoding"警告

我目前正在处理一个在编译时发出以下警告的Java项目:/src/com/myco/apps/AppDBCore.java:439:warning:unmappablecharacterforencodingUTF8[javac]Stringcopyright="�2003-2008MyCompany.Allrightsreserved.";我不确定SO将如何在日期之前呈现字符,但它应该是版权符号,并在警告中显示为菱形中的问号。值得注意的是,该字符正确显示在输出工件中,但警告令人讨厌,并且包含此类的文件有朝一日可能会被文本编辑器触及,从而错误地保存编码...如何将此字符注入(inject

ios - 在 ios9 中替换 stringByAddingPercentEscapesUsingEncoding?

在iOS8及之前我可以使用:NSString*str=...;//someURLNSString*result=[strstringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];在iOS9中stringByAddingPercentEscapesUsingEncoding已被替换为stringByAddingPercentEncodingWithAllowedCharacters:NSString*str=...;//someURLNSCharacterSet*set=???;//wheretofindsetforN

php - json_encode/json_decode - 在 PHP 中返回 stdClass 而不是 Array

观察这个小脚本:$array=array('stuff'=>'things');print_r($array);//prints-Array([stuff]=>things)$arrayEncoded=json_encode($array);echo$arrayEncoded."";//prints-{"stuff":"things"}$arrayDecoded=json_decode($arrayEncoded);print_r($arrayDecoded);//prints-stdClassObject([stuff]=>things)为什么PHP要把JSON对象变成一个类?jso

php - json_encode 返回 NULL?

由于某种原因,“描述”项返回NULL并带有以下代码:这是我的数据库的架构:CREATETABLE`staff`(`id`int(11)NOTNULLAUTO_INCREMENT,`name`longtextCOLLATEutf8_unicode_ci,`description`longtextCOLLATEutf8_unicode_ci,`icon`longtextCOLLATEutf8_unicode_ci,`date`longtextCOLLATEutf8_unicode_ci,`company`longtextCOLLATEutf8_unicode_ci,`companyurl`

ruby - 如何在 ruby​​ 1.8.7 中写入 "string".encode ("us-ascii")?

我正在尝试使用“gmail_xoauth”gem,不幸的是,gem对字符串使用encode("us-ascii"),它仅适用于Ruby1.9.3。我不熟悉Ruby1.9.3中的encode所以我想知道什么是"string".encode("us-ascii")以及我该怎么做为1.8.7编写? 最佳答案 string.encode("us-ascii")方法将字符串中的所有字符转换为美国ASCII7位值。US-ASCII本质上是总共128个字符的纯文本。这种编码在1970年代至90年代的美国计算机上很常见。您现在看到它的原因可能是因为

ruby - Encoding::BINARY 和 Encoding::ASCII-8BIT 之间的区别?

Ruby说Encoding::BINARY和Encoding::ASCII-8BIT是一样的。Encoding::BINARY==Encoding::ASCII_8BIT#=>true我们明确地创建了一个二进制字符串,而ruby​​仍然说它是ASCII_8BIT。String.new("ABC",encoding:Encoding::BINARY).encoding#=>#同样,force_encoding不能创建BINARY,它只会创建一个ASCII-8BIT字符串。BINARY似乎只是ASCII-8BIT的别名。有什么区别吗? 最佳答案

ruby-on-rails - UTF-8 转换不适用于 String#encode 但 Iconv

我用Iconv做了这个:git_log=Iconv.conv'UTF-8','iso8859-1',git_log由于弃用警告,现在我想将其更改为使用String#encode,但我不能,这不起作用:git_log=git_log.encode(Encoding::UTF_8,:invalid=>:replace,:undef=>:replace,:replace=>'')我曾经在这里使用Iconv,它仍然有效:https://github.com/gamersmafia/gamersmafia/blob/master/lib/formatting.rb#L244但是当我用String

ruby - JSON.parse 抛出 Encoding::UndefinedConversionError

在Windows上出现以下错误:Encoding::UndefinedConversionError:"\xEF"fromASCII-8BITtoUTF-8代码:text=File.open(file,'r:binary',&:read);#opensfileandreadsitwithr:binaryflagputstext;#worksigethere,outputsthebelowfilecontentsdata=JSON.parse(text.force_encoding(Encoding::UTF_8));#failsherewithaboveerror注意:我也试过R:UT

ruby - 为什么这里使用 force_encoding ("BINARY")?

当我们安装Rails时,我们得到这个rails“可执行文件”:#!/usr/bin/envruby##ThisfilewasgeneratedbyRubyGems.##Theapplication'railties'isinstalledaspartofagem,and#thisfileisheretofacilitaterunningit.#require'rubygems'version=">=0"ifARGV.firststr=ARGV.firststr=str.dup.force_encoding("BINARY")ifstr.respond_to?:force_encodin