标签: windows-1251

PHP将Windows-1251转换为UTF 8

我有一个小的HTML代码,我需要将其转换为UTF-8.
我用这个iconv("windows-1251", "utf-8", $html);

所有文本都正确转换,但如果文本例如在标记中<i>...</i>,那么它不会转换文本,我会看到像这样的东西???????°?·?°?‚?? ????

php utf-8 character-encoding windows-1251

9
推荐指数
1
解决办法
5万
查看次数

使用 JavaScript 解码 url 编码的 windows-1251 (cp1251) 字符串

我遇到了一个问题,不幸的是,我没有找到正确的解决方案:我需要解码使用 windows-1251 (cp1251) 编码的 url-slice。

\n\n

我知道有这些方法-decodeURI()decodeURIComponent(),但它们仅适用于UTF-8(据我所知)。我发现的解决方案使用已弃用的方法 escape() 和 unescape()。

\n\n

例如有一个序列:

\n\n

%EF%F0%EE%E3%F0%E0%EC%EC%E8%F0%EE%E2%E0%ED%E8%E5 (\xd0\xbf\xd1\x80\xd0\xbe\xd0\xb3\ xd1\x80\xd0\xb0\xd0\xbc\xd0\xbc\xd0\xb8\xd1\x80\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb5)

\n\n

方法decodeURI() 和decodeURIComponent() 将导致异常。

\n\n

将不胜感激的帮助。

\n

javascript decode decoder cp1251 windows-1251

6
推荐指数
1
解决办法
6559
查看次数

错误:用于编码 windows-1251 的不可映射字符 (0x98)

我的项目组装有问题:

D:...\Main.java:112: 错误:编码 windows-1251 的不可映射字符 (0x98)
robots.getBrowserControl().findElement(By.xpath("//div[.='??????) ??']“))。点击();

此错误行: robot.getBrowserControl().findElement(By.xpath("//div[.='????????']")).click();

图片: 错误IDEA 设置。右下角选择了UTF-8。我不确定,但也许它就像符号“?”

图片错误

这是我的 gradle 文件

plugins {
    id 'java'
}

group 'ru.grbi3yh.processthesefiles'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

jar {
    baseName = 'ProcessthFiles'
}


apply plugin: 'application'

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.41.0'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'
}
Run Code Online (Sandbox Code Playgroud)

java encoding intellij-idea gradle windows-1251

6
推荐指数
1
解决办法
3893
查看次数

怎么了?git看到变化没有变化

Git 在干净克隆后立即看到更改。

我只是从服务器克隆项目,并且我的文件之一已标记为已更改。

nick@DESKTOP-NUMBER MINGW64 /d
$ git clone http://nick@host/nick/test.git
Cloning into 'test'...
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Compressing objects: 100% (22/22), done.
remote: Total 27 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (27/27), done.
error: failed to encode 'Var.not' from UTF-8 to Windows-1251

nick@DESKTOP-NUMBER MINGW64 /d
$ cd test/

nick@DESKTOP-NUMBER MINGW64 /d/test (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged …
Run Code Online (Sandbox Code Playgroud)

git encode utf-8 windows-1251

4
推荐指数
1
解决办法
1982
查看次数

HttpClient抛出System.ArgumentException:'windows-1251'不是受支持的编码名称

我正在写WinPhone 8.1应用程序.代码非常简单,适用于大多数情况:

string htmlContent;
using (var client = new HttpClient())
{
    htmlContent = await client.GetStringAsync(GenerateUri());
}
_htmlDocument.LoadHtml(htmlContent);
Run Code Online (Sandbox Code Playgroud)

但有时会抛出异常

htmlContent = await client.GetStringAsync(GenerateUri());
Run Code Online (Sandbox Code Playgroud)

InnerException {System.ArgumentException:'windows-1251'不是受支持的编码名称.参数名称:System.Globalization.EncodingTable.internalGetCodePageFromName(String name)的名称,
位于System.Net.Http.HttpContent的System.Globalization.EncodingTable.GetCodePageFromName(String name).<> c__DisplayClass1.b__0(任务任务)} System.Exception {System.ArgumentException}

HttpClient是否支持1251编码?如果没有,我该如何避免这个问题呢?或者是目标页面问题?或者我错了什么?

c# httpclient character-encoding windows-phone-8.1 windows-1251

3
推荐指数
1
解决办法
2831
查看次数

为什么Python String连接与俄语文本一起使用但string.format()不能

我正在尝试解析(并转义)存储在Windows-1251字符编码中的CSV文件的行.使用这个优秀的答案来处理这种编码我最终得到了这一行来测试输出,由于某种原因,这是有效的:

print(row[0]+','+row[1])
Run Code Online (Sandbox Code Playgroud)

输出:

??????? ??????? ???????????,1 ????
Run Code Online (Sandbox Code Playgroud)

虽然这条线不起作用:

print("{0},{1}".format(*row))
Run Code Online (Sandbox Code Playgroud)

输出此错误:

Name,Variant

Traceback (most recent call last):
  File "Russian.py", line 26, in <module>
    print("{0},{1}".format(*row))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 2-3: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)

以下是CSV的前两行:

Name,Variant
??????? ??????? ???????????,1 ????
Run Code Online (Sandbox Code Playgroud)

如果它有帮助,这里是Russian.py的完整来源:

import csv
import cgi
from chardet.universaldetector import UniversalDetector
chardet_detector = UniversalDetector()

def charset_detect(f, chunk_size=4096):
    global chardet_detector
    chardet_detector.reset()
    while 1:
        chunk = f.read(chunk_size)
        if not chunk: break
        chardet_detector.feed(chunk)
        if chardet_detector.done: break
    chardet_detector.close()
    return chardet_detector.result …
Run Code Online (Sandbox Code Playgroud)

python csv character-encoding windows-1251

2
推荐指数
1
解决办法
248
查看次数