String case: Difference between revisions

→‎{{header|Zig}}: zigstr project has moved; update link in TODO
(Add task to arm assembly raspberry pi)
(→‎{{header|Zig}}: zigstr project has moved; update link in TODO)
 
(10 intermediate revisions by 9 users not shown)
Line 314:
ALPHABETA
alphabeta</pre>
=={{header|AArch64 Assembly}}==
{{works with|as|Raspberry Pi 3B version Buster 64 bits <br> or android 64 bits with application Termux }}
<syntaxhighlight lang AArch64 Assembly>
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program strcase64.s */
 
/************************************/
/* Constantes */
/************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
 
/************************************/
/* Initialized data */
/************************************/
.data
szMessResult: .asciz "Result: \n"
szString: .asciz "alphaBETA"
szCarriageReturn: .asciz "\n"
szMessStart: .asciz "Program 64 bits start.\n"
/************************************/
/* UnInitialized data */
/************************************/
.bss
sBuffer: .skip 80
sBuffex1: .skip 80
/************************************/
/* code section */
/************************************/
.text
.global main
main: // entry of program
ldr x0,qAdrszMessStart
bl affichageMess
ldr x1,qAdrszString
ldr x3,qAdrsBuffer
ldr x4,qAdrsBuffex1
mov x6,#0b100000 // 1 -> bit 5
mov x2,#0
1:
ldrb w0,[x1,x2] // load byte of string
mov x5,x0
cmp x0,#'A' // select alpha characters lower or upper
blt 3f
cmp x0,#'z'
bgt 3f
cmp x0,#'Z'
ble 2f
cmp x0,#'a'
bge 2f
b 3f
2:
orr x0,x0,x6 // converion in lower case (1 -> bit 5)
bic x5,x0,x6 // converion in upper case (0 -> bit 5)
3:
strb w0,[x3,x2] // store lower character
strb w5,[x4,x2] // store upper character
cmp x0,#0 // end string ?
add x2,x2,#1 // increment index character
bne 1b // loop
 
 
ldr x0,qAdrszMessResult
bl affichageMess
ldr x0,qAdrsBuffer
bl affichageMess
ldr x0,qAdrszCarriageReturn
bl affichageMess
ldr x0,qAdrsBuffex1
bl affichageMess
ldr x0,qAdrszCarriageReturn
bl affichageMess
100: // standard end of the program
mov x0, #0 // return code
mov x8, #EXIT // request to exit program
svc 0 // perform the system call
qAdrszString: .quad szString
qAdrsBuffer: .quad sBuffer
qAdrsBuffex1: .quad sBuffex1
qAdrszMessResult: .quad szMessResult
qAdrszCarriageReturn: .quad szCarriageReturn
qAdrszMessStart: .quad szMessStart
/***************************************************/
/* ROUTINES INCLUDE */
/***************************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeARM64.inc"
 
</syntaxhighlight>
{{Out}}
<pre>
Program 64 bits start.
Result:
alphabeta
ALPHABETA
</pre>
=={{header|Action!}}==
{{libheader|Action! Tool Kit}}
Line 821 ⟶ 916:
Title case: AlphaBETA</pre>
 
==={{header|CommodoreChipmunk BASICBasic}}===
{{works with|Chipmunk Basic|3.6.4}}
<syntaxhighlight lang="qbasic">10 s$ = "alphaBETA"
20 print "Original string: ";s$
30 print "To Lower case: ";lcase$(s$)
40 print "To Upper case: ";ucase$(s$)</syntaxhighlight>
 
==={{header|Commodore BASIC}}===
The example here is based on AppleSoft BASIC, however, Commodore machines have a slightly different interpretation of ASCII:
 
Line 915 ⟶ 1,016:
 
==={{header|Liberty BASIC}}===
{{works with|Just BASIC}}
{{works with|Run BASIC}}
<syntaxhighlight lang="lb">
input$ ="alphaBETA"
Line 930 ⟶ 1,033:
lower$ = LCase(s$) ;lowercase</syntaxhighlight>
 
==={{header|QBASICQBasic}}===
{{works with|QBasic|1.1}}
{{works with|QuickBasic|4.5}}
Line 939 ⟶ 1,042:
 
==={{header|Run BASIC}}===
{{works with|Just BASIC}}
{{works with|Liberty BASIC}}
<syntaxhighlight lang="runbasic">a$ ="alphaBETA"
Line 1,455 ⟶ 1,560:
EasyLang does not have string case functions. The functions provided below only work with ASCII.
<syntaxhighlight lang="easylang">
func$ toUpper s$ .
proc toUppercase string$ . result$ .
for ic$ =in 1strchars to len strings$
code = strcode substr stringc$ i 1
if code >= 97 and code <= 122
code -= 32
.
resultres$ &= strchar code
.
return res$
.
func$ toLower s$ .
proc toLowercase string$ . result$ .
for ic$ =in 1strchars to len strings$
code = strcode substr stringc$ i 1
if code >= 65 and code <= 90
code += 32
.
resultres$ &= strchar code
.
return res$
.
string$ = "alphaBETA"
print string$
callprint toUppercasetoUpper string$ result$
print resulttoLower string$
result$ = ""
call toLowercase string$ result$
print result$
</syntaxhighlight>
{{out}}
Line 1,515 ⟶ 1,619:
OUTPUT (LowerCased);
OUTPUT (TitleCased);</syntaxhighlight>
 
=={{header|Ecstasy}}==
The methods on <code>String</code> are <code>toUppercase()</code> and <code>toLowercase()</code>:
 
<syntaxhighlight lang="ecstasy">
module test {
void run() {
@Inject Console console;
console.print($"{"alphaBETA".toLowercase()=}");
console.print($"{"alphaBETA".toUppercase()=}");
}
}
</syntaxhighlight>
 
{{out}}
<pre>
x$ xec test
"alphaBETA".toLowercase()=alphabeta
"alphaBETA".toUppercase()=ALPHABETA
</pre>
 
=={{header|Elena}}==
ELENA 46.x:
<syntaxhighlight lang="elena">import system'culture;
Line 1,524 ⟶ 1,648:
string s1 := "alphaBETA";
// Alternative 1
console.writeLine(s1.lowerCase());
console.writeLine(s1.upperCase());
// Alternative 2
console.writeLine(s1.toLower(currentLocale));
console.writeLine(s1.toUpper(currentLocale));
Line 1,563 ⟶ 1,682:
lower = toLower s
upper = toUpper s</syntaxhighlight>
 
=={{header|EMal}}==
 
<syntaxhighlight lang="emal">
var samples = text["alphaBETA", "ação", "o'hare O'HARE o’hare don't", "Stroßbùrri", "ĥåçýджк", "DŽLjnj"]
for each var sample in samples
writeLine(" original : " + sample)
writeLine(" lower : " + sample.lower())
writeLine(" upper : " + sample.upper())
writeLine()
end
</syntaxhighlight>
{{out}}
<pre>
original : alphaBETA
lower : alphabeta
upper : ALPHABETA
 
original : ação
lower : ação
upper : AÇÃO
 
original : o'hare O'HARE o’hare don't
lower : o'hare o'hare o’hare don't
upper : O'HARE O'HARE O’HARE DON'T
 
original : Stroßbùrri
lower : stroßbùrri
upper : STROßBÙRRI
 
original : ĥåçýджк
lower : ĥåçýджк
upper : ĤÅÇÝДЖК
 
original : DŽLjnj
lower : džljnj
upper : DŽLJNJ
 
</pre>
 
=={{header|Erlang}}==
Line 2,773 ⟶ 2,931:
Lower case : alphabeta
</pre>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
##
var s := 'exAmpLe sTrinG';
s.ToLower.Println;
s.ToUpper.Println;
</syntaxhighlight>
{{out}}
<pre>
example string
EXAMPLE STRING
</pre>
 
 
 
=={{header|Peloton}}==
Line 3,640 ⟶ 3,813:
ALPHABETA
ALPHABETA
</pre>
 
=={{header|Uiua}}==
{{works with|Uiua|0.11.1}}
<syntaxhighlight lang="uiua">
¯"alphaBETA" # swapcase
⌵"alphaBETA" # upper
¯⌵"alphaBETA" # lower
±"alphaBETA123" # case mask 1=upper, -1=lower, 0=neither
</syntaxhighlight>
{{out}}
<pre>
"ALPHAbeta"
"ALPHABETA"
"alphabeta"
[¯1 ¯1 ¯1 ¯1 ¯1 1 1 1 1 0 0 0]
</pre>
 
Line 3,775 ⟶ 3,964:
 
The 'Utf8' class recently acquired the first four of the above methods though with considerably wider (albeit still incomplete) Unicode coverage. In particular the upper case variants 'ẞ' and 'Ÿ' are now supported - the former was introduced into official German orthography in 2017 (though is optional) and, of course, now round-trips. Title case for 4 supported digraphs is automatically applied by the ''capitalize'' or ''title'' methods when they are the first character of the string (or, word, in the case of the latter).
<syntaxhighlight lang="ecmascriptwren">import "./str" for Str, Utf8
 
var strs = ["alphaBETA", "ação", "o'hare O'HARE o’hare don't"]
Line 3,979 ⟶ 4,168:
try stdout_wr.print("upper: {s}\n", .{upper});
 
// TODO use https://githubcodeberg.comorg/jecolondude_the_builder/zigstr
}</syntaxhighlight>
 
1

edit