Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert Cardinal numbers into Ordinal ones

Tags:

c++

ordinals

mfc

Is there an easy way to convert the number 1, 2, 3, ... to "1st", "2nd", "3rd", ..., and in such a way that I can give the function a language and have it return me the correct form for the language I'm targeting? Either standard C++ (stl or boost OK), MFC or ATL, win32 api or a small, single-purpose and free library that I can download from somewhere. Thanks.

like image 395
Roel Avatar asked Sep 25 '08 20:09

Roel


1 Answers

I doubt whether it is possible at all, since in many languages this form will depend on the context, like gender or case of the noun it describes and different languages will require different kind of context information to allow to determine the correct form.

EDIT: E.g. in Polish it is "5-ta klasa" (5th class) vs. "5-ty miesiąc" (5th month) vs. "w 5-tym miesiącu" (in the 5th month).

like image 78
Jacek Szymański Avatar answered Sep 23 '22 07:09

Jacek Szymański