Page 1 of 1

toUpper() and toLower() in cyrillic

Posted: January 21st, 2013, 5:18 am
by Anne
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

Re: toUpper() and toLower() in cyrillic

Posted: January 23rd, 2013, 6:08 pm
by Gregory Martin
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;

Re: toUpper() and toLower() in cyrillic

Posted: January 30th, 2013, 4:14 am
by Anne
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.