Utf 8 日本SRT文件乱码,可以';t确定要用iconv修复的编码
我有一个srt文件,摘录:Utf 8 日本SRT文件乱码,可以';t确定要用iconv修复的编码,utf-8,character-encoding,iconv,mojibake,srt,Utf 8,Character Encoding,Iconv,Mojibake,Srt,我有一个srt文件,摘录: 2 00:00:36,208 --> 00:00:39,667 Èá óå óêïôþóù, ÃïõÜéíôæåëóôéí! 3 00:00:57,917 --> 00:01:00,917 Ãéáôß ôñÝ÷åéò, ÃïõÜéíôæåëóôéí; Óïõ ðÞñá äþñï ãåíåèëßùí. 4 00:01:00,958 --> 00:01:03,208 Äåí ðåéñÜæåé, äåí ÷ñåéáæüôáí íá ìïõ ðÜñåéò
2
00:00:36,208 --> 00:00:39,667
Èá óå óêïôþóù, ÃïõÜéíôæåëóôéí!
3
00:00:57,917 --> 00:01:00,917
Ãéáôß ôñÝ÷åéò, ÃïõÜéíôæåëóôéí;
Óïõ ðÞñá äþñï ãåíåèëßùí.
4
00:01:00,958 --> 00:01:03,208
Äåí ðåéñÜæåé, äåí ÷ñåéáæüôáí
íá ìïõ ðÜñåéò êÜôé.
5
00:01:03,250 --> 00:01:06,375
Óïõ ðÞñá ëßãï êïñìü äÝíôñïõ.
Êáé èá ôï öáò.
6
00:01:06,417 --> 00:01:08,875
Ùñáßá. ¸ôóé êé áëëéþò
èá Ýôñùãá êïñìü.
7
00:01:08,917 --> 00:01:10,208
Äåí èá Ýôñùãåò.
8
00:01:10,208 --> 00:01:11,000
Íáé. ÂëÝðåéò...
9
00:01:11,000 --> 00:01:12,417
...üëá ôá ðñÜãìáôá ðïõ Þèåëåò
íá ìïõ êÜíåéò...
10
00:01:12,417 --> 00:01:13,958
...ó÷åäßáæá íá ôá êÜíù ìüíïò ìïõ.
据推测,这些是日文字幕,但显然是由于编码问题造成的。我试图找出如何纠正它并最终转换为UTF-8。有人有什么想法吗
文件输出:UTF-8 Unicode(带BOM)文本,带CRLF行终止符
可在此处获取文件进行测试:
您拥有的是一份从字符集转换为编码方案的文档,但文档源是在字符集中编码的。转码到UTF-8后,添加了一个U+FEFF字节顺序标记()和几个引号(U+201C,U+201D) 语言为希腊语,更正后的第二副标题顺序为:
2
00:00:36,208 --> 00:00:39,667
Θα σε σκοτώσω, Γουάιντζελστιν!
英文翻译为“”
要反转/更正它,请执行以下操作:
#!/usr/bin/perl
use strict;
use warnings;
use Encode qw[];
(@ARGV == 1 && -f $ARGV[0])
or die qq[Usage: $0 <file>];
my $file = shift @ARGV;
my ($octets, $string);
# Read all the octets from the file
$octets = do {
open my $fh, '<:raw', $file
or die qq[Could not open '$file' for reading: '$!'];
local $/; <$fh>
};
# Decode the octets using the UTF-8 encoding scheme
$string = Encode::decode('UTF-8', $octets, Encode::FB_CROAK);
# Remove all code points greater than U+00FF
$string =~ s/[^\x00-\xFF]//g;
# Encode the string using the ISO-8859-1 encoding
$octets = Encode::encode('ISO-8859-1', $string);
# Decode the octets using the ISO-8859-7 encoding
$string = Encode::decode('ISO-8859-7', $octets);
# Encode the string using the UTF-8 encoding
$octets = Encode::encode('UTF-8', $string);
# Output the octets on standard output
print $octets;
#/usr/bin/perl
严格使用;
使用警告;
使用编码qw[];
(@ARGV==1&&f$ARGV[0])
或死qq[用法:$0];
my$file=shift@ARGV;
我的($octets,$string);
#读取文件中的所有八位字节
$octets=do{
打开我的$fh,“您拥有的是一个从字符集转换到编码方案的文档,但文档源在字符集中编码。转换到UTF-8后,添加了一个U+FEFF字节顺序标记()和一些引号(U+201C,U+201D)
语言为希腊语,更正后的第二副标题顺序为:
2
00:00:36,208 --> 00:00:39,667
Θα σε σκοτώσω, Γουάιντζελστιν!
英文翻译为“”
要反转/更正它,请执行以下操作:
从UTF-8编码方案解码文档
删除所有大于U+00FF的代码点
使用ISO-8859-1编码对文档进行编码
使用ISO-8859-7编码将文档转换为UTF-8编码方案
上述内容在Perl中的实现:
#!/usr/bin/perl
use strict;
use warnings;
use Encode qw[];
(@ARGV == 1 && -f $ARGV[0])
or die qq[Usage: $0 <file>];
my $file = shift @ARGV;
my ($octets, $string);
# Read all the octets from the file
$octets = do {
open my $fh, '<:raw', $file
or die qq[Could not open '$file' for reading: '$!'];
local $/; <$fh>
};
# Decode the octets using the UTF-8 encoding scheme
$string = Encode::decode('UTF-8', $octets, Encode::FB_CROAK);
# Remove all code points greater than U+00FF
$string =~ s/[^\x00-\xFF]//g;
# Encode the string using the ISO-8859-1 encoding
$octets = Encode::encode('ISO-8859-1', $string);
# Decode the octets using the ISO-8859-7 encoding
$string = Encode::decode('ISO-8859-7', $octets);
# Encode the string using the UTF-8 encoding
$octets = Encode::encode('UTF-8', $string);
# Output the octets on standard output
print $octets;
!/usr/bin/perl
严格使用;
使用警告;
使用编码qw[];
(@ARGV==1&&f$ARGV[0])
或死qq[用法:$0];
my$file=shift@ARGV;
我的($octets,$string);
#读取文件中的所有八位字节
$octets=do{
打开我的$fh,'对chansen的侦察非常好!可惜文件没有标记为日语,但这与此无关。我确实尝试了脚本,最终得到了一个编码完美的希腊srt文件。对chansen的侦察非常好!可惜文件没有标记为日语,但与此无关我尝试了脚本,最终得到了一个编码完美的希腊srt文件。