使用Symfony2.3.4和PHP5.6.3以及PHPExcel1.8.0
有没有办法解决这个问题?
见,当我打电话
$objPHPExcel->getProperties()
->setCreator($creator)
->setLastModifiedBy($creator)
->setTitle($name);
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel,
$ext == 'xls' ? 'Excel5' : 'Excel2007');
$objWriter->save('downloads/' . $name . '.' . $ext);
文件的名称必须是西班牙语,因此我需要使用á,é,í等字符。
标题和名称最终都会将这些类型的字符替换为
Ã-
(适用于í
),ó
(适用于ó
)等。
感谢
答案 0 :(得分:2)
这是一个典型的UTF-8问题。对于我的解释,我将使用ó
字符或LATIN SMALL LETTER O WITH ACUTE,其字符代码点为U+00F3
。编码为UTF-8时,需要两个字节:0xC3
和0xB3
。
那么,如果我们查找具有这两个字节的代码点的字符,我们会看到什么?
https://codepoints.net/U+00C3(Ã
- 带有TILDE的拉丁文大写字母A)
https://codepoints.net/U+00B3(³
- SUPERSCRIPT THREE)
据我所知,PHPExcel正确处理UTF-8。这里的问题可能是操作系统不支持UTF-8。例如,Windows使用UTF-16来存储文件名。 Unix将它们存储为BLOB和individual programs determine what encoding to use when decoding filenames。
所以,我没有明确回答你的错误,我只知道如何诊断这个特定的症状。但希望这会让你走上正轨。
答案 1 :(得分:1)
简单:
private static readonly Lazy<CorsOptions> SignalrCorsOptions = new Lazy<CorsOptions>(() =>
{
return new CorsOptions
{
PolicyProvider = new CorsPolicyProvider
{
PolicyResolver = context =>
{
var policy = new CorsPolicy();
policy.AllowAnyOrigin = true;
policy.AllowAnyMethod = true;
policy.AllowAnyHeader = true;
policy.SupportsCredentials = false;
return Task.FromResult(policy);
}
}
};
});
app.Map("/signalr", map =>
{
// Setup the CORS middleware to run before SignalR.
// By default this will allow all origins. You can
// configure the set of origins and/or http verbs by
// providing a cors options with a different policy.
map.UseCors(SignalrCorsOptions.Value);
var hubConfiguration = new HubConfiguration
{
// You can enable JSONP by uncommenting line below.
// JSONP requests are insecure but some older browsers (and some
// versions of IE) require JSONP to work cross domain
EnableJSONP = true
};
// Run the SignalR pipeline. We're not using MapSignalR
// since this branch already runs under the "/signalr"
// path.
map.RunSignalR(hubConfiguration);
});
感谢