Parsing ⅛ and ⅓ Characters from actxserver Outlook Mail object Body and Converting to Floats
Mostrar comentarios más antiguos
Hi all
I am parsing Outlook mails in Matlab by actxserver and regexp.
Some mails contain fraction characters as below

The ½,¼,¾ characters are read ok, but the eighths (⅛,⅜,⅝,⅞) and thirds (⅓,⅔) are present in the body property of the mail object as "?" [char(63)] as per below screenshot from the command-line print of the mail body.

Matlab recognises only ¼ ½ ¾ [char(188:190)] so I guess I need to access non ASCII chars. Its not clear whether the issue is Matlab's 16bit unicode or the actxserver object. The characters are available on Windows Vista Arial font as U+215C,E etc
You can verify this for yourself by emailing yourself a mail with the subjectline
⅛¼⅓⅜½⅝⅔¾⅞
and then running the code below in matlab to regexp this subjectline of the mail in your inbox. Put a breakpoint at the regexp line to inspect what the subject variable looks like, should see "?" in there.
Two questions here:
1. How could I extend Matlab's ASCII set to read these characters
2. Is there a neat way to convert them into equivalent floats (3¼ -- > 3.25) within regexp ?
Grateful for any suggestions here
Mark
% Below function will need to be adapted depending on how your outlook folders are set up:
function myfrac = TestReadFractions
outlook = actxserver('Outlook.Application');
mapi = outlook.GetNamespace('mapi');
folder1 = mapi.Folders(1);
myaccount = folder1.Item(2);
inboxmails = myaccount.Folders.Item(2).Folders.Item(9).Items;
count = inboxmails.Count;
myfrac = {};
for i = count:-1:count-10
if strcmp(inboxmails.Item(i).SenderEmailAddress,'yourname@youraddress.com')
subject = inboxmails.Item(i).Subject; % Mail Subject-Line
myfrac = regexp(subject,'\x215c','match');
end
end
Respuestas (1)
Walter Roberson
el 3 de Feb. de 2014
regexprep('ABC','B','\x215c')
4 comentarios
Mark Whirdy
el 3 de Feb. de 2014
Editada: Mark Whirdy
el 5 de Feb. de 2014
Walter Roberson
el 3 de Feb. de 2014
Ah if it is code page 65001 then that is UTF-8 . You might have to take "subject" and pass it through native2unicode().
Could you show me the result of
subject + 0
? I do not have MATLAB installed on any MS Windows systems to test with.
Mark Whirdy
el 5 de Feb. de 2014
Editada: Mark Whirdy
el 5 de Feb. de 2014
Walter Roberson
el 5 de Feb. de 2014
Sorry, I am not familiar with how InternetCodePage properties work.
Categorías
Más información sobre Use COM Objects in MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!