标签: character-encoding

将非标准字符转换为标准版本

我需要将非标准字符更改为标准字符,例如'.我怎么能用PHP做到这一点?现在我只需要更改撇号,但知道如何改变其他类似双引号等等会很好.

php ascii character-encoding special-characters

0
推荐指数
1
解决办法
791
查看次数

在Centos而不是Windows上运行时,将XML转换为JSON会导致未知字符

我有一个Java servlet,它获取RSS feed将它们转换为JSON.它在Windows上运行良好,但在Centos上失败了.

RSS源包含阿拉伯语,它在Centos上显示难以理解的字符.我正在使用这些行来编码RSS提要:

byte[] utf8Bytes = Xml.getBytes("Cp1256");
//  byte[] defaultBytes = Xml.getBytes();

String roundTrip = new String(utf8Bytes, "UTF-8");
Run Code Online (Sandbox Code Playgroud)

我在Glassfish和Tomcat上尝试过它.两者都有同样的问题; 它适用于Windows,但在Centos上失败.这是怎么造成的,我该如何解决?

java linux unicode servlets character-encoding

0
推荐指数
1
解决办法
426
查看次数

GZIP字符串压缩无法解压缩'£'字符

我有以下代码用于压缩字符串(为清楚起见,删除了错误和资源处理):

import java.util.zip.GZIP*;
import java.io.*;
import java.util.zip.GZIPOutputStream;
import org.apache.commons.io.IOUtils;
import com.Ostermiller.util.Base64;

//Code to compress the string
ByteArrayOutputStream output = new ByteArrayOutputStream(65536);
BufferedWriter writer = new BufferedWriter(
           new OutputStreamWriter(new GZIPOutputStream(output)));
writer.write(stringContents);
String compressedString =  new String(Base64.encode(output.toByteArray()));

...

//Code to decompress the string
byte[] compressedData = Base64.decode(compressedString.getBytes());
BufferedInputStream reader = new BufferedInputStream(
           new GZIPInputStream(new ByteArrayInputStream(compressedData)));
String uncompressedString = IOUtils.toString(reader, "UTF-8");
Run Code Online (Sandbox Code Playgroud)

我们在尝试编码然后解码其中带有'£'的字符串时遇到错误.具体来说,字符串压缩OK,但在尝试解压缩字符串时,我们得到以下堆栈跟踪:

sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java(Compiled Code))
at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java:287)
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java:337)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:223)
at java.io.InputStreamReader.read(InputStreamReader.java:208)
at java.io.Reader.read(Reader.java:113)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1128)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1104)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:1078)
at …
Run Code Online (Sandbox Code Playgroud)

java compression gzip character-encoding

0
推荐指数
1
解决办法
1795
查看次数

为什么短*而不是char*为字符串?char*和unsigned char*之间的区别?

正如标题所说,我有两个问题.

编辑:为了澄清,他们实际上char并没有使用和short,他们确保它们是特定typedef的8位和16位.那么实际类型称为UInt8UInt16.

1.问题

iTunes的SDK使用unsigned short*其中一个字符串是必要的.使用它而不是char*/ unsigned char*?有什么好处?如何将其转换为char*,以及使用此类型时有何不同?

2.问题

我只看到char*必须存储字符串的时候.我什么时候应该使用unsigned char*,或者它没有任何区别?

c unsigned short char character-encoding

0
推荐指数
1
解决办法
1101
查看次数

字符编码html - utf-8而不是latin1

我有一个基本上只是的网页模板:

<html>
<body>...</body>
</html>
Run Code Online (Sandbox Code Playgroud)

但是我的浏览器(正确地)将正文中的文本解释为latin1.所以我改成了:

<?xml encoding="utf-8"?>
<html>
<body>...</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这解决了问题,并且在我的特定浏览器(Linux 3.x上的Chrome 17.x)中将文本正确解释为UTF-8,但是......

什么是指定html页面中的文本以UTF-8编码的最佳方式(最新的浏览器兼容和向前兼容)?

html unicode utf-8 character-encoding web

0
推荐指数
1
解决办法
3493
查看次数

Zend PDF charset - 没有支持克罗地亚的图表 - 尝试了一切请帮助

这是我创建PDF文档的代码我看不到čćžšđ我尝试导入.TTF文件但是无法正确导入和使用ttf请帮助$ pdf = new Zend_Pdf();

// Add new page to the document
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page; 

// Draw something on a page
// Set font
$page->setFont(Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_COURIER), 20); 

///tried to import TTF not working
//$goodDogCoolFont = Zend_Pdf_Font::fontWithPath('dokumenti/cro.TTF');
//$page->setFont($goodDogCoolFont, 36);

// Draw text
#
$page->setFillColor(Zend_Pdf_Color_Html::color('#990000'));
$page->drawText('Ra??š?ž?un za apartman AID '.$this->ukupnacjena[1]['AID'] , 10, 800, 'Windows-1250');// UTF-8 Also doesnt work

pdfData = $pdf->render(); 

$filename = $this->ukupnacjena[1]['OD-DO'];

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="'.$filename.'.pdf"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');
echo $pdfData;
Run Code Online (Sandbox Code Playgroud)

pdf zend-framework character-encoding

0
推荐指数
1
解决办法
892
查看次数

Carrierwave俄语文件名

我需要保存带有俄语名称或音译文件名的文件.我试试这个:

1)在document_uploader中:

def filename
  @name ||= "#{Russian::transliterate(original_filename)}.#{file.extension}" if original_filename.present?
end
Run Code Online (Sandbox Code Playgroud)

2)在document.rb中:

我使用相同的逻辑创建before_create回调方法,但没有看到任何结果.

上传后的文件名称如下:"______________.doc"

我该做什么?

file-upload ruby-on-rails utf-8 character-encoding carrierwave

0
推荐指数
1
解决办法
1440
查看次数

java字符串vs mysql字符串

mysql> CREATE database testing CHARACTER SET utf16;
Query OK, 1 row affected (0.00 sec)

mysql> USE testing;
Database changed

mysql> CREATE TABLE t (str varchar(64));
Query OK, 0 rows affected (0.43 sec)

mysql> INSET INTO t values ("1234567891234567");
Query OK, 1 row affected (0.00 sec)
Run Code Online (Sandbox Code Playgroud)

=============================

然后我有一段java代码

Connection connection = DriverManager.getConnection(url, usr, pass);
Statement statement = connection.createStatement();

statement.execute("USE  testing");

ResultSet rst = statement.executeQuery("SELECT str, LENGTH(str) FROM t;");
while (rst.next())
             System.out.print("java length: " + rst.getString(1).length() 
                     + "\nmysql length: " + rst.getInt(2)); …
Run Code Online (Sandbox Code Playgroud)

java mysql string character-encoding

0
推荐指数
1
解决办法
411
查看次数

写入文件时出现EncoderFallbackException

我正在阅读MS Office Word 2010文件(.docx),然后搞乱它,然后将其写入新文件.我添加的唯一字符是在大多数键盘上找到的字符(字母,数字,标点符号......),我也会将现有字符移动一点点.

        StreamReader sr = new StreamReader(File.OpenRead("fs.docx"));
        string foo = sr.ReadToEnd();
        sr.Close();
        string foo2 = EncryptFile(foo);
        StreamWriter sw = new StreamWriter(File.Create("sal.docx"));
        sw.Write(foo2); // THIS IS WHERE THE EXCEPTION HAPPENS
        sw.Close();
        foo = DecryptFile(foo2);
        StreamWriter sww = new StreamWriter(File.Create("sal2.docx"));
        sww.Write(foo);
        sww.Close();

    public static string Salt(string Input)
    {
        Random rand = new Random();
        string Output = "";
        string BigSalt = "";
        int SaltIncrement = rand.Next(4, 8);
        for (int i = 0; i < 10; i++) {
            BigSalt += FindCipherPlainText.Substring(rand.Next(0, FindCipherPlainText.Length), …
Run Code Online (Sandbox Code Playgroud)

c# debugging encoding character-encoding

0
推荐指数
1
解决办法
1828
查看次数

解码UTF-16文本

我有一个Java servlet,它通过HTTP GET请求从上游系统接收数据.此请求包含一个名为"text"的参数和另一个名为"charset"的参数,该参数指示text参数的编码方式:

如果我指示上游系统向我发送文本T?并调试servlet请求参数,我会看到以下内容:

request.getParameter("charset") == "UTF-16LE"
request.getParameter("text").getBytes() == [0, 84, 1, 0]
Run Code Online (Sandbox Code Playgroud)

此字符串中两个字符的代码点(十六进制)为:

[T]  0054
[?]  0100
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何将其转换byte[]回String "T?".我应该提一下,我并不完全信任charset并怀疑它可能正在使用UTF-16BE.

java servlets character-encoding

0
推荐指数
1
解决办法
2196
查看次数