C 替换字符问题仍未解决

C 替换字符问题仍未解决,c,replace,C,Replace,当 输出包含替换字符 GetWindowText(spotify_window_handle, title, title_length) char* spotify_title(int window_handle) { int title_length = GetWindowTextLength(window_handle); if(title_length != 0) { char* title; tit

输出包含替换字符

GetWindowText(spotify_window_handle, title, title_length)
char* spotify_title(int window_handle)
{
    int title_length = GetWindowTextLength(window_handle);
        if(title_length != 0)
        {
            char* title;
            title = (char*)malloc((++title_length) * sizeof *title );
            if(title != NULL)
            {
                GetWindowText(window_handle, title, title_length);
                if(strcmp(title, "Spotify") != 0)
            {
                return title;
            }
            else
            {
                return "Spotify is not playing anything right now. Type !botnext command to restart playback.";
            }
        }
        else
        {
            printf("PLUGIN: Unable to allocate memory for title\n");
        }
        free(title);
    }
    else
    {
        printf("PLUGIN: Unable to get Spotify window title\n");
    }
}
// End of Spotify get title function
我需要更换“�" 带“-”。我不久前发布了这个问题,但没有粘贴我的代码,所以答案我假设我使用了wchar\u t作为标题,但我没有。标题是char*。 任何帮助都将不胜感激,我是C代码的“新手”,有时我在一些基本/奇怪的行为上有很大的困难

这是我的密码:

Spotify - Philip Glass � Glassworks Opening

根据您上面的评论,我假设该字符是0x96=En破折号字符

GetWindowText(spotify_window_handle, title, title_length)
char* spotify_title(int window_handle)
{
    int title_length = GetWindowTextLength(window_handle);
        if(title_length != 0)
        {
            char* title;
            title = (char*)malloc((++title_length) * sizeof *title );
            if(title != NULL)
            {
                GetWindowText(window_handle, title, title_length);
                if(strcmp(title, "Spotify") != 0)
            {
                return title;
            }
            else
            {
                return "Spotify is not playing anything right now. Type !botnext command to restart playback.";
            }
        }
        else
        {
            printf("PLUGIN: Unable to allocate memory for title\n");
        }
        free(title);
    }
    else
    {
        printf("PLUGIN: Unable to get Spotify window title\n");
    }
}
// End of Spotify get title function

我在代码中没有看到你的支票”�“--另外,
strcmp()
如果两个字符串相同,则返回零,因此您可能需要类似于
if(strncmp(title,“Spotify-”,10)==0)
--还要在调试器中检查�“实际上是(十六进制)什么是“”,请?你想用“-”替换“emtpy”-字符串吗?你是什么意思?alk可能你的浏览器没有显示我需要替换的字符,例如,这是字符哦是的,确实,在编辑模式下打开你的问题允许我复制不可见(至少对我来说)字符。