lower$ and Upper$ only english based?
BlitzMax Forums/BlitzMax Programming/lower$ and Upper$ only english based?
| ||
The Lower and Upper is very simply because it only convert english chars and have see CharLowerW and CharUpperW in user32 Windows (if correct dll). Due my application (not the game I creating) is a multi language application, how can this been impletered and is still Linux aware? |
| ||
Excuse my ignorance but what other languages use letter case? |
| ||
Russian? :-) |
| ||
Excuse my ignorance but what other languages use letter case? Greek, for one. |
| ||
Well, that's a couple of Cyrillic languages covered. How's about Bulgarian too. I imagine most "latin" scripts will work with the standard Upper/Lower ... but you never knows. |
| ||
example it dosent convert danish chars. only a-z. There is a tons of EU languages that use extended Latin sets and these is not converted. Also I known I could easy create one that only support most basic extended latin chars, but if I can use a unicoded based that can convert most languages, it would been pretty nice. This is of course example include Russia. Mightbeen this would been a little project based on a file including example arabic support (yes I known its diffecent, it mere the output format here)? |
| ||
Its some sort of this, just with much more languages supported:Strict TCase.Init() Print TCase.uCase$("test of danish æøå chars") Print TCase.LCase$("TEST OF DANISH ÆØÅ chars") Type TCase Global L:Int[]=New Int[65536] Global H:Int[]=New Int[65536] Function init() 'with some extended Latin chars Local Low$="àáâãäåæçqwertyuiopèéêëìíîïasdfghjklñòóôõöøzxcvbnmßùúûüýÿ" Local Hi$="ÀÁÃÃÄÅÆÇQWERTYUIOPÈÉÊËÌÍÎÏASDFGHJKLÑÒÓÔÕÖØZXCVBNMßÙÚÛÜÝŸ" For Local i=0 To 65535 L[i]=i H[i]=i Next For Local i=1 To Len(Low$) L[Asc(Mid(Low$, i, 1))]=Asc(Mid(Hi$, i, 1)) H[Asc(Mid(Hi$, i, 1))]=Asc(Mid(Low$, i, 1)) Next EndFunction Function LCase$(txt$) Local result$="" For Local i=1 To Len(txt$) Local c=Asc(Mid(txt$, i, 1)) result$=result$+Chr(h[c]) Next Return result$ EndFunction Function UCase$(txt$) Local result$="" For Local i=1 To Len(txt$) Local c=Asc(Mid(txt$, i, 1)) result$=result$+Chr(l[c]) Next Return result$ EndFunction EndType |
| ||
I imagine most "latin" scripts will work with the standard Upper/Lower ... but you never knows. Except 90% of latin languages. As far as I know, only English has no accents, tildes or spacial chars.Sspanish have lost of them, also Italian, French, Danish, Svenska, German, Turkish... that's to say that the default method won't work in most languages and it is not 'exactly' well thought. That's a very usual problem of this kind of functions being coded by someone that talks and writes only english :D (no ofense intended here!) But how can we understand a english-only uppercase/lowercase conversion mechanism on a unicode language? IMHO, It is a bit unconsistent. There's a windows API that handles this automatically in a fast way, covering most languages. Extern "win32" Function CharUpperA$z(Param1$z) Function CharLowerA$z(Param1$z) End Extern Print CharUpperA("OtoñoáéíóúÁÉÍÓÚñ") Print CharLowerA("OtoñoáéíóúÁÉÍÓÚÑ") I'm sure linux and MacOsX have the same counterpart functions. the windows API works much better than the windows default built in upper/lower methods of BlitzMax |
| ||
I gonna think to use the unicode code version of it in PureBasic, output the string to a file and then use it in BliztMax so most languages is covered like the above function. Howover the unicode version of the win command is not imported in blitzmax, so I only think only the default codebase works? (example no russian support when used in example in English OS)? |
| ||
Well, here's a MacOS implementation that makes use of NSString's support for multiple languages: Requires some tweaking of the existing blitz_string.c to make this work, and you'd have to put it in blitz_string.macos.m and import that only under MacOS (in blitz.bmx). However, it's worked when I tested it, so that's one platform down. Something that's worth noting in the Apple docs though is that string length may be different. Their example being that the German character "ß" becomes "SS" when capitalized, and if then made lowercase will simply be "ss" rather than "ß" again. |
| ||
I created this application in Pure Basic:Dim C(64*1024) Procedure.s MyUCase(text.s) Protected temp.s temp = text If CharUpper_(temp) ProcedureReturn temp Else ProcedureReturn text EndIf EndProcedure Procedure.s MyLCase(text.s) Protected temp.s temp = text If CharLower_(temp) ProcedureReturn temp Else ProcedureReturn text EndIf EndProcedure Macro UCase(arg) MyUCase(arg) EndMacro Macro LCase(arg) MyLCase(arg) EndMacro For i=1 To 65535 a$=LCase(Chr(i)) b$=UCase(Chr(i)) If a$<>b$ aa=Asc(a$) bb=Asc(b$) If aa<>bb C(aa)=bb EndIf EndIf Next s$=Chr(9)+Chr(9)+"s$="+Chr(34) count=0 For i=1 To 65535 If C(i)<>0 s$=s$+Str(i) s$=s$+"=" s$=s$+Str(c(i)) s$=s$+";" count=count+1 If count=10 s$=s$+Chr(34)+Chr(13)+Chr(10) s$=s$+Chr(9)+Chr(9) s$=s$+"s$=s$+"+Chr(34) count=0 EndIf EndIf Next If OpenFile(0, "c:\cap.ini") WriteStringN(0, s$) CloseFile(0) Delay(250) EndIf And in BlitzMax its came up with this (added to code archives and no hence to post it twice): http://www.blitzmax.com/codearcs/codearcs.php?code=2509 |