toUpper() and toLower() in cyrillic

Discussions about CSEntry
Post Reply
Anne
Posts: 84
Joined: January 11th, 2012, 12:55 am

toUpper() and toLower() in cyrillic

Post by Anne » January 21st, 2013, 5:18 am

Getting closer and closer and closer with my cyrillic application, but now my colleagues have reported a new problem: The ToUpper() and ToLower() functions does not work with cyrillc. And I've tested it: My colleagues are correct.

(Guess for now I'll just instruct the interviewers to use lowercase when searching through the classifications, but it would be nice if it worked..)

Anne

Gregory Martin
Posts: 1338
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: toUpper() and toLower() in cyrillic

Post by Gregory Martin » January 23rd, 2013, 6:08 pm

You're right that toupper and tolower only work with Latin characters. Can you tell me whether the Upper Case flag works for you? That is, add an alpha field to your data entry application and type in lowercase Cyrillic text. Does it show up in uppercase? If so, then I can easily resolve this issue for you. The code that implements the Upper Case flag is different from the toupper/tolower code, so I can use the Upper Case flag code if it works.

In the meantime, you can accomplish such a task with user-defined functions. See below, and the attached application.
alpha (46) cyrillicLower = "абвгдежзийклмнопрстуфхцчшщъыьэюяёђѓєѕіїјљњћќўџ";
alpha (46) cyrillicUpper = "АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯЁЂЃЄЅІЇЈЉЊЋЌЎЏ";


function alpha (500) toupperCyrillic(alpha (500) str)

    str =
toupper(str); // for latin characters
    
    
numeric idx,cpos;

    
do idx = length(strip(str)) while idx >= 1 by -1

        cpos =
pos(str[idx:1],cyrillicLower);

        
if cpos then
            str[idx:
1] = cyrillicUpper[cpos:1];
        
endif;

    
enddo;

    toupperCyrillic = str;

end;


function alpha (500) tolowerCyrillic(alpha (500) str)

    str =
tolower(str); // for latin characters

    
numeric idx,cpos;

    
do idx = length(strip(str)) while idx >= 1 by -1

        cpos =
pos(str[idx:1],cyrillicUpper);

        
if cpos then
            str[idx:
1] = cyrillicLower[cpos:1];
        
endif;

    
enddo;

    tolowerCyrillic = str;

end;
Attachments
cyr.zip
(2.3 KiB) Downloaded 209 times

Anne
Posts: 84
Joined: January 11th, 2012, 12:55 am

Re: toUpper() and toLower() in cyrillic

Post by Anne » January 30th, 2013, 4:14 am

Thank you for nice instructions on how to fix toUpper and toLower in cyrillic.

I did test the Upper case flag, and it does not work: If I type lowercase cyrillic in an alpha field, it also shows up in lowercase, so I guess this is not an easy thing to fix in CSPro itself, then.

Anyway: Your solution works fine, so as long as one knows about this, is not really a problem.

Post Reply