MATLAB gui中的法语口音

时间:2013-07-04 13:49:18

标签: matlab user-interface non-ascii-characters

我正在研究一个带有gui的MATLAB程序。我想要法语文本标签和按钮,但它不起作用。例如,代码中的'Paramètres'一词在gui上变为Paramètres

我检查了文件编码,它是utf-8。我该怎么做才能解决这个问题?

这是我在代码中使用的一个命令的简单示例: tab2 = uitab('v0', hTabGroup, 'title','Paramètres des canaux');

感谢。

6 个答案:

答案 0 :(得分:2)

如何使用HTML?:

figure
hTabGroup = uitabgroup;
drawnow;
tab2 = uitab('v0',hTabGroup,'title','<html>Param&egrave;tres des canaux</html>');

有关HTML字符代码的列表,请参阅here

答案 1 :(得分:1)

添加重音aigu使用

title('{Param\''etres des canaux}','interpreter','latex')

添加重音坟墓使用

 title('{Param\`etres des canaux}','interpreter','latex')

答案 2 :(得分:1)

我在this stackoverflow page找到了答案。基本上,我只需要在创建GUI之前将MATLAB编码设置为UTF-8。命令很简单:

feature('DefaultCharacterSet','UTF-8');

就是这样!

答案 3 :(得分:0)

我很难将字符串从SO复制粘贴到MATLAB,因为“è”由于某种原因显示为char(65533)(而不是正确的char(232))...

无论如何,我把一个小的转换实用程序放在一起,将字符串或单元格转换为它们的HTML-in-HTML等价物,以补充horchler的答案:

function html = toHTML(strings)

    %% Initialize

    % Basic IO check
    if ~iscellstr(strings) && ~ischar(strings)
        error(...
            'toHTML:invalid_input',...
            ['Invalid input class: ''%s''.\n',...
            'Supported input types are ''char'' or a ''cell'' containing ''char''.'], class(strings));
    end

    % Provide support for
    %  - Single and multiline line char arrays    
    %  - Cellstrings
    wasChar = ischar(strings);
    if wasChar 
        if size(strings,1) > 1            
            strings(:, end+1) = char(10);            
        end
        strings = {strings}; 
    end

    %% Convert all strings to their unicode representation in HTML

    % Just for abbreviation 
    uf = {'UniformOutput',false};

    % Convert all characters to their HTML unicode representation 
    html = cellfun(@transpose, strings, uf{:});
    html = cellfun(@(x) cellstr(num2str(x(:)+0)), html, uf{:});
    html = cellfun(@(x) cellfun(@(y) ['&#' strtrim(y) ';'],x, uf{:}), html, uf{:});

    % Include HTML tags
    html = cellfun(@(x) ['<html>' [x{:}] '</html>'], html, uf{:});

    % Take care of newlining
    html = regexprep(html, '&#10;', '<br>');
    html = regexprep(html, '<br></html>$', '</html>');

    % Make output type consistent with input type
    if wasChar
        html = [html{:}]; 
    end

end

我目前正在将此提交给FEX。如果有人知道这样的事情是否已经存在,请告诉我。

答案 4 :(得分:0)

我用这种技术解决了这个问题。

在您的终端中写下:

export LC_CTYPE="en_US.ISO-8859-1"

然后,启动Matlab并尝试:

title('été');

如果可行,您只需创建一个脚本,在启动Matlab之前执行导出命令。在.bashrc文件中,自定义脚本启动Matlab等...

我的解决方法只是创建一个自定义脚本(即我的/ home / username / bin目录中的“mat”):

#!/bin/bash
cd /home/username/Matlab
export LC_CTYPE="en_US.ISO-8859-1"
/path/to/matlab/matlab

然后,我在/ home / username目录的.bashrc文件中创建了一个别名,以启动脚本“mat”

alias m="/home/proy/bin/mat &"

答案 5 :(得分:0)

如果它在matlab脚本中,你用强调字符存储你的字符串,尝试将matlab脚本的编码更改为ANSI(例如,使用Notepad ++或SublimeText)。