Replacing special character 'É' to 'E'

조회 수: 47 (최근 30일)
Pete sherer
Pete sherer . 2022년 11월 28일
댓글: Jonas . 2022년 11월 29일
Is there a Matlab function to replace the special characters (like 'É') to the regular UTF-8 or ISO-8859-1?
  댓글 수: 1
Stephen23 2022년 11월 28일
"regular UTF-8 or ISO-8859-1"
Both UTF-8 (encodes all Unicode characters) and ISO-8859-1 include "É"... Perhaps you meant to ask something like "how to remove diacritics from characters?", which would match your question title.

댓글을 달려면 로그인하십시오.

채택된 답변

Jonas 2022년 11월 28일
looks like there are only manual solutions.
Stackoverflow is your friend ;-)
  댓글 수: 5
Jonas 2022년 11월 29일
also it is qeustionable to do this whole thing since the change of letters can change th emeaning of the words, also in German for example, ä, ö and ü are changed to ae, oe and ue, but the same procedure does not make sence in other languages like turkish

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Stephen23 2022년 11월 28일
편집: Stephen23 님. 2022년 11월 28일
"Is there a Matlab function to replace the special characters (like 'É')"
You can call Python from MATLAB, and it can do the heavy-lifting:
inp = 'É';
baz = @(v)char(v(1)); % only need the first decomposed character.
out = baz(py.unicodedata.normalize('NFKD',inp)) % to remove diacritics.
out = 'E'
Read more:

John D'Errico
John D'Errico 2022년 11월 28일
편집: John D'Errico 님. 2022년 11월 28일
Easy peasy.
str = 'ABCDEFGHIJKÉÉÀÀÄÄabcdefghijkl'
str = 'ABCDEFGHIJKÉÉÀÀÄÄabcdefghijkl'
ans = 'ABCDEFGHIJKEEÀÀÄÄabcdefghijkl'
If there are other special characters you want replaced, strrep will handle them too, but it looks like you would need to do them one at a time with strrep. But other tools would certainly work too. Certainly regexp, but I've never been very good at regular expressions. :) This will work though:
badchar = 'ÉÀÄ';
goodchar = 'EAA';
[u,v] = ismember(str,'ÉÀÄ');
str(u) = goodchar(v(u))
str = 'ABCDEFGHIJKEEAAAAabcdefghijkl'


Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by