小编Vol*_*ing的帖子

在iOS中本地化字符串:默认(后备)语言?

有没有办法设置在应用程序不支持设备UI语言时使用的默认语言?

示例:我的应用已本地化为英语和德语:

// en.lproj:
"POWER_TO_THE_PEOPLE_BTN" = "Power";
"POWER_PLUG_BTN" = "Power";

// de.lproj:
"POWER_TO_THE_PEOPLE_BTN"  = "Macht";
"POWER_PLUG_BTN" = "Spannung";
Run Code Online (Sandbox Code Playgroud)

现在,如果我在设置为Italian应用程序的UI语言的设备上运行应用程序将使用键字符串POWER_TO_THE_PEOPLE_BTNPOWER_PLUG_BTN.

必须有一种方法来指定应用程序在这种情况下使用的默认(回退)语言.

从上面的例子中可以清楚地看出,使用英文字符串作为键是行不通的.

我现在看到的唯一选择是使用NSLocalizedStringWithDefaultValue而不是NSLocalizedString.

localization internationalization ios

39
推荐指数
4
解决办法
3万
查看次数

HttpWebRequest无法访问http://xn--fanbys-exa.org/episodes.m4a.rss

我有一个奇怪的问题访问以下网址:

http://xn--fanbys-exa.org/episodes.m4a.rss


这是代码:

    void WebRequestButton_Click( object sender, RoutedEventArgs e )
    {
        string url = "http://xn--fanbys-exa.org/episodes.m4a.rss"; 

        if ( Uri.IsWellFormedUriString( url, UriKind.Absolute ) )
        {
            HttpWebRequest webRequest = ( HttpWebRequest )HttpWebRequest.Create( url );
            if ( webRequest != null )
            {
                webRequest.BeginGetResponse( new AsyncCallback( ReadWebRequestCallback ), webRequest ); 
            }
        }
    }

    private void ReadWebRequestCallback( IAsyncResult callbackResult )
    {
        HttpWebRequest request = ( HttpWebRequest )callbackResult.AsyncState;
        HttpWebResponse response = null;

        try
        {
            response = ( HttpWebResponse )request.EndGetResponse( callbackResult );
        }
        catch ( Exception e ) …
Run Code Online (Sandbox Code Playgroud)

httpwebrequest windows-phone-7 windows-phone-7.1

7
推荐指数
1
解决办法
538
查看次数

混合Objective-C和C++代码

我有一个Objective-C/C++应用程序,它使用C++库提供的功能.

其中一个C++类包含这样的枚举:

class TheClass
{
public:
[...]

enum TheEnum
{
    YES,
    NO,
};

[...]
};
Run Code Online (Sandbox Code Playgroud)

包括(使用#import -if that matters-)带有Objective-C/C++源文件(*.mm)中的上述类声明的头文件将使编译失败,因为预处理器将用术语"替换"为"YES" (BOOL)1"("(BOOL)0"同样为"NO").

有没有办法解决这个问题而不重命名枚举的值?

c++ objective-c name-clash c-preprocessor

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

PHP:下载的二进制文件在结尾处获得一个额外的字节(0x0a)

PHP版本5.2.17

我有以下用于下载二进制文件的PHP脚本:

<?php

$download_dir = '.';
$download_file = $_GET['get'];

$path = $download_dir.'/'.$download_file;

if(file_exists($path))
{
    $size = filesize($path);

    header('Content-Type: application/x-download');
    header('Content-Disposition: attachment; filename='.$download_file);
    header('Content-Length: '.$size);
    header('Content-Transfer-Encoding: binary');

    readfile($path);
}else{
    echo "<font face=$textfont size=3>";
    echo "<center><br><br>The file [<b>$download_file</b>] is not available for download.<br>";
}
?>
Run Code Online (Sandbox Code Playgroud)

用于调用此脚本的URL:

HTTP://myserver/cur/downloads/test.php GET = FooBar_Setup.exe

下载有效但下载的文件附加了一个附加字节(0x0a).
响应的标头还显示Content-Length比所请求文件的大小大一个字节:

HTTP/1.1 200 OK
Date: Mon, 05 Dec 2011 10:29:32 GMT
Server: Apache/2.2
Content-Disposition: attachment; filename=FooBar_Setup.exe
Content-Length: 1417689
Content-Transfer-Encoding: binary
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/x-download
Run Code Online (Sandbox Code Playgroud)

服务器上文件的大小为1417688字节.

我已经验证 …

php

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