Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/String_case
note: String manipulation

View file

@ -0,0 +1,16 @@
;Task:
Take the string     '''alphaBETA'''     and demonstrate how to convert it to:
:::*   upper-case     and
:::*   lower-case
<br>
Use the default encoding of a string literal or plain ASCII if there is no string literal in your language.
Note: In some languages alphabets toLower and toUpper is not reversable.
Show any additional case conversion functions &nbsp; (e.g. swapping case, capitalizing the first letter, etc.) &nbsp; that may be included in the library of your language.
{{Template:Strings}}
<br><br>

View file

@ -0,0 +1,3 @@
V s = alphaBETA
print(s.uppercase())
print(s.lowercase())

View file

@ -0,0 +1,15 @@
UCASE CSECT
USING UCASE,R15
MVC UC,PG
MVC LC,PG
OC UC,=16C' ' or X'40' uppercase
NC LC,=16X'BF' and X'BF' lowercase
XPRNT PG,L'PG print original
XPRNT UC,L'UC print uc
XPRNT LC,L'LC print lc
BR R14
PG DC CL9'alphaBETA'
UC DS CL(L'PG)
LC DS CL(L'PG)
YREGS
END UCASE

View file

@ -0,0 +1,31 @@
UCASE CSECT
USING UCASE,R15
MVC UC,PG
MVC LC,PG
TR UC,TABLEU TR uppercase
TR LC,TABLEL TR lowercase
XPRNT PG,L'PG print original
XPRNT UC,L'UC print uc
XPRNT LC,L'LC print lc
BR R14
PG DC CL9'alphaBETA'
UC DS CL(L'PG)
LC DS CL(L'PG)
TABLEU DC 256AL1(*-TABLEU)
ORG TABLEU+C'a'
DC C'ABCDEFGHI'
ORG TABLEU+C'j'
DC C'JKLMNOPQR'
ORG TABLEU+C's'
DC C'STUVWXYZ'
ORG
TABLEL DC 256AL1(*-TABLEL)
ORG TABLEL+C'A'
DC C'abcdefghi'
ORG TABLEL+C'J'
DC C'jklmnopqr'
ORG TABLEL+C'S'
DC C'stuvwxyz'
ORG
YREGS
END UCASE

View file

@ -0,0 +1,3 @@
$string:="alphaBETA"
$uppercase:=Uppercase($string)
$lowercase:=Lowercase($string)

View file

@ -0,0 +1,98 @@
.lf case6502.lst
.cr 6502
.tf case6502.obj,ap1
;------------------------------------------------------
; String Case for the 6502 by barrym95838 2013.04.07
; Thanks to sbprojects.com for a very nice assembler!
; The target for this assembly is an Apple II with
; mixed-case output capabilities. Apple IIs like to
; work in '+128' ascii, so this version leaves bit 7
; alone, and can be used with either flavor.
; 6502s work best with data structures < 256 bytes;
; several instructions would have to be added to
; properly deal with longer strings.
; Tested and verified on AppleWin 1.20.0.0
;------------------------------------------------------
; Constant Section
;
StrPtr = $6 ;0-page temp pointer (2 bytes)
Low = $8 ;0-page temp low bound
High = $9 ;0-page temp high bound
CharOut = $fded ;Specific to the Apple II
BigA = "A" ;'A' for normal ascii
BigZ = "Z" ;'Z' " " "
LittleA = "a" ;'a' " " "
LittleZ = "z" ;'z' " " "
;======================================================
.or $0f00
;------------------------------------------------------
; The main program
;
main ldx #sTest ;Point to the test string
lda /sTest
jsr puts ;print it to stdout
jsr toUpper ;convert to UPPER-case
jsr puts ;print it
jsr toLower ;convert to lower-case
jmp puts ;print it and return to caller
;------------------------------------------------------
toUpper ldy #LittleA
sty Low ;set up the flip range
ldy #LittleZ
bne toLow2 ;return via toLower's tail
;------------------------------------------------------
toLower ldy #BigA
sty Low ;set up the flip range
ldy #BigZ
toLow2 sty High
; ;return via fall-thru to flip
;------------------------------------------------------
; Given a NUL-terminated string at A:X, flip the case
; of any chars in the range [Low..High], inclusive;
; only works on the first 256 bytes of a long string
; Uses: StrPtr, Low, High
; Preserves: A, X
; Trashes: Y
;
flip stx StrPtr ;init string pointer
sta StrPtr+1
ldy #0
pha ;save A
flip2 lda (StrPtr),y ;get string char
beq flip5 ;done if NUL
cmp Low
bcc flip4 ;if Low <= char <= High
cmp High
beq flip3
bcs flip4
flip3 eor #$20 ; then flip the case
sta (StrPtr),y
flip4 iny ;point to next char
bne flip2 ;loop up to 255 times
flip5 pla ;restore A
rts ;return
;------------------------------------------------------
; Output NUL-terminated string @ A:X; strings longer
; than 256 bytes are truncated there
; Uses: StrPtr
; Preserves: A, X
; Trashes: Y
;
puts stx StrPtr ;init string pointer
sta StrPtr+1
ldy #0
pha ;save A
puts2 lda (StrPtr),y ;get string char
beq puts3 ;done if NUL
jsr CharOut ;output the char
iny ;point to next char
bne puts2 ;loop up to 255 times
puts3 pla ;restore A
rts ;return
;------------------------------------------------------
; Test String (in '+128' ascii, Apple II style)
;
sTest .as -"Alpha, BETA, gamma, {[(<123@_>)]}."
.az -#13
;------------------------------------------------------
.en

View file

@ -0,0 +1,60 @@
UpperCase:
;input: A0 = pointer to the string's base address.
;alters the string in-place.
MOVE.B (A0),D0 ;load a letter
BEQ .Terminated ;we've reached the null terminator.
CMP.B #'a',D0 ;compare to ascii code for a
BCS .overhead ;if less than a, keep looping.
CMP.B #'z',D0 ;compare to ascii code for z
BHI .overhead ;if greater than z, keep looping
AND.B #%1101111,D0 ;this "magic constant" turns lower case to upper case, since they're always 32 apart.
.overhead:
MOVE.B D0,(A0)+ ;store the letter back and increment the pointer.
;If this isn't an alphabetical character, D0 won't change and this store won't affect the string at all.
;If it was a letter, it will have been changed to upper case before storing back.
BRA UpperCase ;next letter
.Terminated:
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LowerCase:
MOVE.B (A0),D0 ;load a letter
BEQ .Terminated ;we've reached the null terminator.
CMP.B #'A',D0 ;compare to ascii code for A
BCS .overhead ;if less than A, keep looping.
CMP.B #'Z',D0 ;compare to ascii code for Z
BHI .overhead ;if greater than Z, keep looping
OR.B #%00100000,D0 ;this "magic constant" turns upper case to lower case, since they're always 32 apart.
.overhead:
MOVE.B D0,(A0)+ ;store the result and get ready to read the next letter.
BRA LowerCase ;next letter
.Terminated:
RTS
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ToggleCase:
MOVE.B (A0),D0 ;load a letter and inc the pointer to the next letter
BEQ .Terminated ;we've reached the null terminator.
MOVE.B D0,D1 ;copy the letter
AND.B #%11011111 ;convert the copy to upper case so we can check it.
CMP.B #'A',D1 ;compare to ascii code for A
BCS overhead ;if less than A, keep looping.
CMP.B #'Z',D1 ;compare to ascii code for Z
BHI overhead ;if greater than Z, keep looping
EOR.B #%00100000,D0 ;swaps the case of the letter
overhead:
MOVE.B D0,(A0)+ ;store the result
BRA ToggleCase ;next letter
.Terminated:
RTS

View file

@ -0,0 +1,37 @@
org 100h
jmp demo
;;; Convert CP/M string under [HL] to upper case
unext: inx h
ucase: mov a,m ; Get character <- entry point is here
cpi '$' ; Done?
rz ; If so, stop
cpi 'a' ; >= 'a'?
jc unext ; If not, next character
cpi 'z'+1 ; <= 'z'?
jnc unext ; If not, next character
sui 32 ; Subtract 32
mov m,a ; Write character back
jmp unext
;;; Convert CP/M string under [HL] to lower case
lnext: inx h
lcase: mov a,m ; Get character <- entry point is here
cpi '$' ; Done?
rz ; If so, stop
cpi 'A' ; >= 'A'?
jc lnext ; If not, next character
cpi 'Z'+1 ; <= 'Z'?
jnc lnext ; If not, next character
adi 32 ; Subtract 32
mov m,a ; Write character back
jmp lnext
;;; Apply to given string
demo: call print ; Print without change
lxi h,str
call ucase ; Make uppercase
call print ; Print uppercase version
lxi h,str
call lcase ; Make lowercase (fall through to print)
print: lxi d,str ; Print string using CP/M call
mvi c,9
jmp 5
str: db 'alphaBETA',13,10,'$'

View file

@ -0,0 +1,31 @@
#!/usr/local/bin/a68g --script #
# Demonstrate toupper and tolower for standard ALGOL 68
strings. This does not work for multibyte character sets. #
INT l2u = ABS "A" - ABS "a";
PROC to upper = (CHAR c)CHAR:
(ABS "a" > ABS c | c |: ABS c > ABS "z" | c | REPR ( ABS c + l2u ));
PROC to lower = (CHAR c)CHAR:
(ABS "A" > ABS c | c |: ABS c > ABS "Z" | c | REPR ( ABS c - l2u ));
# Operators can be defined in ALGOL 68 #
OP (CHAR)CHAR TOLOWER = to lower, TOUPPER = to upper;
# upper-cases s in place #
PROC string to upper = (REF STRING s)VOID:
FOR i FROM LWB s TO UPB s DO s[i] := to upper(s[i]) OD;
# lower-cases s in place #
PROC string to lower = (REF STRING s)VOID:
FOR i FROM LWB s TO UPB s DO s[i] := to lower(s[i]) OD;
main: (
STRING t := "alphaBETA";
string to upper(t);
printf(($"uppercase: "gl$, t));
string to lower(t);
printf(($"lowercase: "gl$, t))
)

View file

@ -0,0 +1,42 @@
begin
% algol W doesn't have standard case conversion routines, this is one way %
% such facilities could be provided %
% converts text to upper case %
% assumes the letters are contiguous in the character set (as in ASCII) %
% would not work in EBCDIC (as the original algol W implementations used) %
procedure upCase( string(256) value result text ) ;
for i := 0 until 255 do begin
string(1) c;
c := text( i // 1 );
if c >= "a" and c <= "z"
then begin
text( i // 1 ) := code( decode( "A" )
+ ( decode( c ) - decode( "a" ) )
)
end
end upCase ;
% converts text to lower case %
% assumes the letters are contiguous in the character set (as in ASCII) %
% would not work in EBCDIC (as the original algol W implementations used) %
procedure dnCase( string(256) value result text ) ;
for i := 0 until 255 do begin
string(1) c;
c := text( i // 1 );
if c >= "A" and c <= "Z"
then begin
text( i // 1 ) := code( decode( "a" )
+ ( decode( c ) - decode( "A" ) )
)
end
end dnCase ;
string(256) text;
text := "alphaBETA";
upCase( text );
write( text( 0 // 40 ) );
dnCase( text );
write( text( 0 // 40 ) );
end.

View file

@ -0,0 +1,9 @@
AlphLower'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ'
AlphUpper'ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ*'
AlphUpper[AlphLower'I'm using APL!']
I*M USING APL*
AlphLower'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ*'
AlphUpper'ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ'
AlphLower[AlphUpper'I'm using APL!']
i*m using apl*

View file

@ -0,0 +1,4 @@
BEGIN {
a = "alphaBETA";
print toupper(a), tolower(a)
}

View file

@ -0,0 +1,4 @@
BEGIN {
a = "alphaBETA";
print toupper(substr(a, 1, 1)) tolower(substr(a, 2))
}

View file

@ -0,0 +1,34 @@
INCLUDE "D2:CHARTEST.ACT" ;from the Action! Tool Kit
PROC UpperCase(CHAR ARRAY text,res)
BYTE i
res(0)=text(0)
FOR i=1 TO res(0)
DO
res(i)=ToUpper(text(i))
OD
RETURN
PROC LowerCase(CHAR ARRAY text,res)
BYTE i
res(0)=text(0)
FOR i=1 TO res(0)
DO
res(i)=ToLower(text(i))
OD
RETURN
PROC Main()
CHAR ARRAY text="alphaBETA"
CHAR ARRAY upper(20),lower(20)
UpperCase(text,upper)
LowerCase(text,lower)
Put(125) PutE() ;clear screen
PrintF("Original string: ""%S""%E",text)
PrintF("Upper-case string: ""%S""%E",upper)
PrintF("Lower-case string: ""%S""%E",lower)
RETURN

View file

@ -0,0 +1,3 @@
var string:String = 'alphaBETA';
var upper:String = string.toUpperCase();
var lower:String = string.toLowerCase();

View file

@ -0,0 +1,9 @@
with Ada.Characters.Handling, Ada.Text_IO;
use Ada.Characters.Handling, Ada.Text_IO;
procedure Upper_Case_String is
S : constant String := "alphaBETA";
begin
Put_Line (To_Upper (S));
Put_Line (To_Lower (S));
end Upper_Case_String;

View file

@ -0,0 +1,35 @@
#include <hopper.h>
#proto swapcase(_X_)
main:
// literal:
String to process = "alphaBETA", {"String to process: ",String to process}println
{"UPPER: ",String to process} upper,println
{"LOWER: ",String to process} lower,println
{"SWAP CASE: "}
s="", let( s := _swap case(String to process)),{s}println
// arrays:
vArray=0, {5,5} new array(vArray), vArray=String to process
{"ARRAY UPPER: \n",vArray} upper,println
{"ARRAY LOWER: \n",vArray} lower,println
[1:2:end,1:2:end]get(vArray),upper, put(vArray)
[2:2:end,2:2:end]get(vArray),lower, put(vArray)
{"INTERVAL ARRAY UPPER/LOWER: \n",vArray},println
exit(0)
.locals
swapcase(_X_)
nLen=0, {_X_}len,mov(nLen)
__SWAPCASE__:
if( [nLen:nLen]get(_X_),{"upper"}!typechar? )
lower
else
upper
end if
put(_X_)
--nLen,{nLen}jnz(__SWAPCASE__)
{_X_} // put processed string into the stack...
back

View file

@ -0,0 +1,61 @@
use framework "Foundation"
-- TEST -----------------------------------------------------------------------
on run
ap({toLower, toTitle, toUpper}, {"alphaBETA αβγδΕΖΗΘ"})
--> {"alphabeta αβγδεζηθ", "Alphabeta Αβγδεζηθ", "ALPHABETA ΑΒΓΔΕΖΗΘ"}
end run
-- GENERIC FUNCTIONS ----------------------------------------------------------
-- toLower :: String -> String
on toLower(str)
set ca to current application
((ca's NSString's stringWithString:(str))'s ¬
lowercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toLower
-- toTitle :: String -> String
on toTitle(str)
set ca to current application
((ca's NSString's stringWithString:(str))'s ¬
capitalizedStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toTitle
-- toUpper :: String -> String
on toUpper(str)
set ca to current application
((ca's NSString's stringWithString:(str))'s ¬
uppercaseStringWithLocale:(ca's NSLocale's currentLocale())) as text
end toUpper
-- A list of functions applied to a list of arguments
-- (<*> | ap) :: [(a -> b)] -> [a] -> [b]
on ap(fs, xs)
set {nf, nx} to {length of fs, length of xs}
set lst to {}
repeat with i from 1 to nf
tell mReturn(item i of fs)
repeat with j from 1 to nx
set end of lst to |λ|(contents of (item j of xs))
end repeat
end tell
end repeat
return lst
end ap
-- Lift 2nd class handler function into 1st class script wrapper
-- mReturn :: Handler -> Script
on mReturn(f)
if class of f is script then
f
else
script
property |λ| : f
end script
end if
end mReturn

View file

@ -0,0 +1 @@
{"alphabeta αβγδεζηθ", "Alphabeta Αβγδεζηθ", "ALPHABETA ΑΒΓΔΕΖΗΘ"}

View file

@ -0,0 +1,5 @@
S$ = "alphaBETA"
UP$ = "" : FOR I = 1 TO LEN(S$) : C = ASC(MID$(S$, I, 1)) : UP$ = UP$ + CHR$(C - (C > 96 AND C < 123) * 32) : NEXT I : ? UP$
LO$ = "" : FOR I = 1 TO LEN(S$) : C = ASC(MID$(S$, I, 1)) : LO$ = LO$ + CHR$(C + (C > 64 AND C < 91) * 32) : NEXT I : ? LO$

View file

@ -0,0 +1,2 @@
main():
uppercase('alphaBETA') + '\n' + lowercase('alphaBETA') + '\n' -> io

View file

@ -0,0 +1,5 @@
str: "alphaBETA"
print ["uppercase :" upper str]
print ["lowercase :" lower str]
print ["capitalize :" capitalize str]

View file

@ -0,0 +1,5 @@
a := "alphaBETA"
StringLower, b, a ; alphabeta
StringUpper, c, a ; ALPHABETA
StringUpper, d, a, T ; Alphabeta (T = title case) eg "alpha beta gamma" would become "Alpha Beta Gamma"

View file

@ -0,0 +1,3 @@
$sString = "alphaBETA"
$sUppercase = StringUpper($sString) ;"ALPHABETA"
$sLowercase = StringLower($sString) ;"alphabeta"

View file

@ -0,0 +1,2 @@
Print: uppercase "alphaBETA";
Print: lowercase "alphaBETA";

View file

@ -0,0 +1,3 @@
s$ = "alphaBETA"
PRINT UCASE$(s$)
PRINT LCASE$(s$)

View file

@ -0,0 +1,4 @@
s$ = "alphaBETA"
print "Original string: "; s$
print "To Lower case: "; lower(s$)
print "To Upper case: "; upper(s$)

View file

@ -0,0 +1,7 @@
INSTALL @lib$+"STRINGLIB"
original$ = "alphaBETA"
PRINT "Original: " original$
PRINT "Lower case: " FN_lower(original$)
PRINT "Upper case: " FN_upper(original$)
PRINT "Title case: " FN_title(original$)

View file

@ -0,0 +1,26 @@
get "libhdr"
// Check whether a character is an upper or lowercase letter
let islower(x) = 'a' <= x <= 'z'
let isupper(x) = 'A' <= x <= 'Z'
// Convert a character to upper or lowercase
let toupper(x) = islower(x) -> x - 32, x
let tolower(x) = isupper(x) -> x + 32, x
// Map a character function over a string
let strmap(f,s) = valof
$( for i=1 to s%0 do s%i := f(s%i)
resultis s
$)
// Convert a string to upper or lowercase
let strtoupper(s) = strmap(toupper,s)
let strtolower(s) = strmap(tolower,s)
let start() be
$( let s = "alphaBETA"
writef(" String: %S*N", s)
writef("Uppercase: %S*N", strtoupper(s))
writef("Lowercase: %S*N", strtolower(s))
$)

View file

@ -0,0 +1,2 @@
Upr -(32×1="a{") # Uppercase ASCII text
Lwr +(32×1="A[") # Lowercase ASCII text

View file

@ -0,0 +1,6 @@
str "alphaBETA"
"alphaBETA"
Upr str
"ALPHABETA"
Lwr str
"alphabeta"

View file

@ -0,0 +1,16 @@
using System;
namespace StringCase
{
class Program
{
public static void Main()
{
String input = scope .("alphaBETA");
input.ToUpper();
Console.WriteLine(input);
input.ToLower();
Console.WriteLine(input);
}
}
}

View file

@ -0,0 +1,4 @@
"ATEBahpla" > : #v_ 25* , @ >48*-v
> :: "`"` \"{"\` * | > , v
> ^
^ <

View file

@ -0,0 +1,2 @@
"alphaBETA":?s
& out$str$(upp$!s \n low$!s)

View file

@ -0,0 +1,3 @@
blsq ) "alphaBETA"^^zz\/ZZ
"ALPHABETA"
"alphabeta"

View file

@ -0,0 +1,21 @@
#include <algorithm>
#include <string>
#include <cctype>
/// \brief in-place convert string to upper case
/// \return ref to transformed string
void str_toupper(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::toupper);
}
/// \brief in-place convert string to lower case
/// \return ref to transformed string
void str_tolower(std::string &str) {
std::transform(str.begin(),
str.end(),
str.begin(),
(int(*)(int)) std::tolower);
}

View file

@ -0,0 +1,12 @@
#include <iostream>
#include <string>
using namespace std;
int main() {
string foo("_upperCas3Me!!");
str_toupper(foo);
cout << foo << endl;
str_tolower(foo);
cout << foo << endl;
return 0;
}

View file

@ -0,0 +1,23 @@
class Program
{
static void Main(string[] args)
{
string input;
Console.Write("Enter a series of letters: ");
input = Console.ReadLine();
stringCase(input);
}
private static void stringCase(string str)
{
char[] chars = str.ToCharArray();
string newStr = "";
foreach (char i in chars)
if (char.IsLower(i))
newStr += char.ToUpper(i);
else
newStr += char.ToLower(i);
Console.WriteLine("Converted: {0}", newStr);
}
}

View file

@ -0,0 +1 @@
System.Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase("exAmpLe sTrinG"));

View file

@ -0,0 +1,36 @@
/* Demonstrate toupper and tolower for
standard C strings.
This does not work for multibyte character sets. */
#include <ctype.h>
#include <stdio.h>
/* upper-cases s in place */
void str_toupper(char *s)
{
while(*s)
{
*s=toupper(*s);
s++;
}
}
/* lower-cases s in place */
void str_tolower(char *s)
{
while(*s)
{
*s=tolower(*s);
s++;
}
}
int main(int argc, char *argv[])
{
char t[255]="alphaBETA";
str_toupper(t);
printf("uppercase: %s\n", t);
str_tolower(t);
printf("lowercase: %s\n", t);
return 0;
}

View file

@ -0,0 +1,4 @@
string(TOUPPER alphaBETA s)
message(STATUS "Uppercase: ${s}")
string(TOLOWER alphaBETA s)
message(STATUS "Lowercase: ${s}")

View file

@ -0,0 +1,30 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. string-case-85.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 example PIC X(9) VALUE "alphaBETA".
01 result PIC X(9).
PROCEDURE DIVISION.
DISPLAY "Example: " example
*> Using the intrinsic functions.
DISPLAY "Lower-case: " FUNCTION LOWER-CASE(example)
DISPLAY "Upper-case: " FUNCTION UPPER-CASE(example)
*> Using INSPECT
MOVE example TO result
INSPECT result CONVERTING "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
TO "abcdefghijklmnopqrstuvwxyz"
DISPLAY "Lower-case: " result
MOVE example TO result
INSPECT result CONVERTING "abcdefghijklmnopqrstuvwxyz"
TO "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
DISPLAY "Upper-case: " result
GOBACK
.

View file

@ -0,0 +1,32 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. string-case-extensions.
DATA DIVISION.
WORKING-STORAGE SECTION.
78 example VALUE "alphaBETA".
01 result PIC X(9).
PROCEDURE DIVISION.
DISPLAY "Example: " example
*> ACUCOBOL-GT
MOVE example TO result
CALL "C$TOLOWER" USING result, BY VALUE 9
DISPLAY "Lower-case: " result
MOVE example TO result
CALL "C$TOUPPER" USING result, BY VALUE 9
DISPLAY "Upper-case: " result
*> Visual COBOL
MOVE example TO result
CALL "CBL_TOLOWER" USING result, BY VALUE 9
DISPLAY "Lower-case: " result
MOVE example TO result
CALL "CBL_TOUPPER" USING result BY VALUE 9
DISPLAY "Upper-case: " result
GOBACK
.

View file

@ -0,0 +1,3 @@
(def string "alphaBETA")
(println (.toUpperCase string))
(println (.toLowerCase string))

View file

@ -0,0 +1,2 @@
<cfset upper = UCase("alphaBETA")>
<cfset lower = LCase("alphaBETA")>

View file

@ -0,0 +1,3 @@
<cfset string = "alphaBETA">
<cfset upper = UCase(string)>
<cfset lower = LCase(string)>

View file

@ -0,0 +1,14 @@
10 rem string case
15 rem rosetta code
20 s$="alphaBETA"
30 print chr$(147);chr$(14)
40 print "The original string is:"
41 print:print tab(11);s$
50 up$="":lo$=""
55 for i=1 to len(s$)
60 c=asc(mid$(s$,i,1))
65 up$=up$+chr$(c or 128)
70 lo$=lo$+chr$(c and 127)
75 next i
80 print:print "Uppercase: ";up$
90 print "Lowercase: ";lo$

View file

@ -0,0 +1,2 @@
CL-USER> (string-upcase "alphaBETA")
"ALPHABETA"

View file

@ -0,0 +1,2 @@
CL-USER> (string-downcase "alphaBETA")
"alphabeta"

View file

@ -0,0 +1,15 @@
MODULE AlphaBeta;
IMPORT StdLog,Strings;
PROCEDURE Do*;
VAR
str,res: ARRAY 128 OF CHAR;
BEGIN
str := "alphaBETA";
Strings.ToUpper(str,res);
StdLog.String("Uppercase:> ");StdLog.String(res);StdLog.Ln;
Strings.ToLower(str,res);
StdLog.String("Lowercase:> ");StdLog.String(res);StdLog.Ln
END Do;
END AlphaBeta.

View file

@ -0,0 +1,4 @@
"alphaBETA".downcase # => "alphabeta"
"alphaBETA".upcase # => "ALPHABETA"
"alphaBETA".capitalize # => "Alphabeta"

View file

@ -0,0 +1 @@
"ĥåçýджк".upcase # => "ĤÅÇÝДЖК"

View file

@ -0,0 +1,7 @@
void main() {
import std.stdio, std.string;
immutable s = "alphaBETA";
s.toUpper.writeln;
s.toLower.writeln;
}

View file

@ -0,0 +1,9 @@
OPEN (1,O,'TT:') ;open video
STR="alphaBETA"
LOCASE STR
DISPLAY (1,STR,10) ;alphabeta
UPCASE STR
DISPLAY (1,STR,10) ;ALPHABETA

View file

@ -0,0 +1,2 @@
PrintLn(UpperCase('alphaBETA'));
PrintLn(LowerCase('alphaBETA'));

View file

@ -0,0 +1,14 @@
String capitalize(String string) {
if (string.isEmpty) {
return string;
}
return string[0].toUpperCase() + string.substring(1);
}
void main() {
var s = 'alphaBETA';
print('Original string: $s');
print('To Lower case: ${s.toLowerCase()}');
print('To Upper case: ${s.toUpperCase()}');
print('To Capitalize: ${capitalize(s)}');
}

View file

@ -0,0 +1,2 @@
writeln(uppercase('alphaBETA'));
writeln(lowercase('alphaBETA'));

View file

@ -0,0 +1,5 @@
let str = "alphaBETA"
print("Lower case: ", str.Lower(), separator: "")
print("Upper case: ", str.Upper(), separator: "")
print("Capitalize: ", str.Capitalize(), separator: "")

View file

@ -0,0 +1,2 @@
["alphaBETA".toUpperCase(),
"alphaBETA".toLowerCase()]

View file

@ -0,0 +1,11 @@
IMPORT STD; //Imports the Standard Library
STRING MyBaseString := 'alphaBETA';
UpperCased := STD.str.toUpperCase(MyBaseString);
LowerCased := STD.str.ToLowerCase(MyBaseString);
TitleCased := STD.str.ToTitleCase(MyBaseString);
OUTPUT (UpperCased);
OUTPUT (LowerCased);
OUTPUT (TitleCased);

View file

@ -0,0 +1,25 @@
proc toUppercase string$ . result$ .
for i = 1 to len string$
code = strcode substr string$ i 1
if code >= 97 and code <= 122
code -= 32
.
result$ &= strchar code
.
.
proc toLowercase string$ . result$ .
for i = 1 to len string$
code = strcode substr string$ i 1
if code >= 65 and code <= 90
code += 32
.
result$ &= strchar code
.
.
string$ = "alphaBETA"
print string$
call toUppercase string$ result$
print result$
result$ = ""
call toLowercase string$ result$
print result$

View file

@ -0,0 +1,10 @@
(string-downcase "alphaBETA")
→ "alphabeta"
(string-upcase "alphaBETA")
→ "ALPHABETA"
(string-titlecase "alphaBETA")
→ "Alphabeta"
(string-randcase "alphaBETA")
→ "alphaBEtA"
(string-randcase "alphaBETA")
→ "AlPHaBeTA"

View file

@ -0,0 +1,15 @@
import system'culture;
public program()
{
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));
console.readChar()
}

View file

@ -0,0 +1,6 @@
String.downcase("alphaBETA")
# => alphabeta
String.upcase("alphaBETA")
# => ALPHABETA
String.capitalize("alphaBETA")
# => Alphabeta

View file

@ -0,0 +1,8 @@
String.downcase("αΒ")
# => αβ
String.upcase("αΒ")
# => ΑΒ
String.capitalize("αΒ")
# => Αβ
String.upcase("ß")
# => SS

View file

@ -0,0 +1,6 @@
import String exposing (toLower, toUpper)
s = "alphaBETA"
lower = toLower s
upper = toUpper s

View file

@ -0,0 +1,2 @@
string:to_upper("alphaBETA").
string:to_lower("alphaBETA").

View file

@ -0,0 +1 @@
=LOWER(A1)

View file

@ -0,0 +1 @@
=UPPER(A1)

View file

@ -0,0 +1 @@
alphaBETA alphabeta ALPHABETA

View file

@ -0,0 +1,3 @@
let s = "alphaBETA"
let upper = s.ToUpper()
let lower = s.ToLower()

View file

@ -0,0 +1,4 @@
"alphaBETA" >lower ! "alphabeta"
"alphaBETA" >upper ! "ALPHABETA"
"alphaBETA" >title ! "Alphabeta"
"ß" >case-fold ! "ss"

View file

@ -0,0 +1,2 @@
printl("alphaBETA".lower())
printl("alphaBETA".upper())

View file

@ -0,0 +1,10 @@
fansh> a := "alphaBETA"
alphaBETA
fansh> a.upper // convert whole string to upper case
ALPHABETA
fansh> a.lower // convert whole string to lower case
alphabeta
fansh> a.capitalize // make sure first letter is capital
AlphaBETA
fansh> "BETAalpha".decapitalize // make sure first letter is not capital
bETAalpha

View file

@ -0,0 +1,38 @@
program example
implicit none
character(9) :: teststring = "alphaBETA"
call To_upper(teststring)
write(*,*) teststring
call To_lower(teststring)
write(*,*) teststring
contains
subroutine To_upper(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("a":"z")
str(i:i) = achar(iachar(str(i:i))-32)
end select
end do
end subroutine To_upper
subroutine To_lower(str)
character(*), intent(in out) :: str
integer :: i
do i = 1, len(str)
select case(str(i:i))
case("A":"Z")
str(i:i) = achar(iachar(str(i:i))+32)
end select
end do
end subroutine To_Lower
end program example

View file

@ -0,0 +1,8 @@
SUBROUTINE UPCASE(TEXT)
CHARACTER*(*) TEXT
INTEGER I,C
DO I = 1,LEN(TEXT)
C = INDEX("abcdefghijklmnopqrstuvwxyz",TEXT(I:I))
IF (C.GT.0) TEXT(I:I) = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"(C:C)
END DO
END

View file

@ -0,0 +1,3 @@
DO I = 1,LEN(TEXT)
TEXT(I:I) = XLATUC(ICHAR(TEXT(I:I)))
END DO

View file

@ -0,0 +1,76 @@
module uplow
implicit none
character(len=26), parameter, private :: low = "abcdefghijklmnopqrstuvwxyz"
character(len=26), parameter, private :: high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
contains
function to_upper(s) result(t)
! returns upper case of s
implicit none
character(len=*), intent(in) :: s
character(len=len(s)) :: t
character(len=1), save :: convtable(0:255)
logical, save :: first = .true.
integer :: i
if(first) then
do i=0,255
convtable(i) = char(i)
enddo
do i=1,len(low)
convtable(iachar(low(i:i))) = char(iachar(high(i:i)))
enddo
first = .false.
endif
t = s
do i=1,len_trim(s)
t(i:i) = convtable(iachar(s(i:i)))
enddo
end function to_upper
function to_lower(s) result(t)
! returns lower case of s
implicit none
character(len=*), intent(in) :: s
character(len=len(s)) :: t
character(len=1), save :: convtable(0:255)
logical, save :: first = .true.
integer :: i
if(first) then
do i=0,255
convtable(i) = char(i)
enddo
do i = 1,len(low)
convtable(iachar(high(i:i))) = char(iachar(low(i:i)))
enddo
first = .false.
endif
t = s
do i=1,len_trim(s)
t(i:i) = convtable(iachar(s(i:i)))
enddo
end function to_lower
end module uplow
program doit
use uplow
character(len=40) :: s
s = "abcdxyz ZXYDCBA _!@"
print *,"original: ",'[',s,']'
print *,"to_upper: ",'[',to_upper(s),']'
print *,"to_lower: ",'[',to_lower(s),']'
end program doit

View file

@ -0,0 +1,6 @@
' FB 1.05.0 Win64
Dim s As String = "alphaBETA"
Print UCase(s)
Print LCase(s)
Sleep

View file

@ -0,0 +1,3 @@
a = "alphaBETA"
println[lc[a]]
println[uc[a]]

View file

@ -0,0 +1 @@
uc["Imbiß"] // Last char is \u00df

View file

@ -0,0 +1 @@
lc[ uc["Imbiß"] ]

View file

@ -0,0 +1,9 @@
window 1
CFStringRef s = @"alphaBETA"
print s
print ucase(s)
print lcase(s)
HandleEvents

View file

@ -0,0 +1,2 @@
LowercaseString("alphaBETA");
UppercaseString("alphaBETA");

View file

@ -0,0 +1,14 @@
extends MainLoop
func _process(_delta: float) -> bool:
var string: String = "alphaBETA"
print(string.to_upper())
print(string.to_lower())
# Note: These will also add/remove underscores.
print("to_camel_case: ", string.to_camel_case())
print("to_pascal_case: ", string.to_pascal_case())
print("to_snake_case: ", string.to_snake_case())
return true # Exit

View file

@ -0,0 +1,8 @@
#define cases
{
x = 'alphaBETA';
y = string_upper(x); // returns ALPHABETA
z = string_lower(x); // returns alphabeta
show_message(y);
show_message(z);
}

View file

@ -0,0 +1,7 @@
Public Sub Main()
Dim sString As String = "alphaBETA "
Print UCase(sString)
Print LCase(sString)
End

View file

@ -0,0 +1,28 @@
package main
import (
"fmt"
"strings"
"unicode"
"unicode/utf8"
)
func main() {
show("alphaBETA")
show("alpha BETA")
// Three digraphs that should render similar to DZ, Lj, and nj.
show("DŽLjnj")
// Unicode apostrophe in third word.
show("o'hare O'HARE ohare don't")
}
func show(s string) {
fmt.Println("\nstring: ",
s, " len:", utf8.RuneCountInString(s), "runes") // DZLjnj
fmt.Println("All upper case: ", strings.ToUpper(s)) // DZLJNJ
fmt.Println("All lower case: ", strings.ToLower(s)) // dzljnj
fmt.Println("All title case: ", strings.ToTitle(s)) // DzLjNj
fmt.Println("Title words: ", strings.Title(s)) // Dzljnj
fmt.Println("Swapping case: ", // DzLjNJ
strings.Map(unicode.SimpleFold, s))
}

View file

@ -0,0 +1,14 @@
package main
import (
"fmt"
"strings"
)
func main() {
a := "Stroßbùrri"
b := "ĥåçýджк"
fmt.Println(strings.ToUpper(a))
fmt.Println(strings.ToUpper(b))
}
}

View file

@ -0,0 +1,4 @@
def str = 'alphaBETA'
println str.toUpperCase()
println str.toLowerCase()

View file

@ -0,0 +1,6 @@
import Data.Char
s = "alphaBETA"
lower = map toLower s
upper = map toUpper s

View file

@ -0,0 +1,4 @@
CHARACTER str = "alphaBETA"
EDIT(Text=str, UpperCase=LEN(str))
EDIT(Text=str, LowerCase=LEN(str))
EDIT(Text=str, UpperCase=1)

View file

@ -0,0 +1,3 @@
100 INPUT PROMPT "String: ":TX$
110 PRINT "Lower case: ";LCASE$(TX$)
120 PRINT "Upper case: ";UCASE$(TX$)

View file

@ -0,0 +1,4 @@
procedure main()
write(map("alphaBETA"))
write(map("alphaBETA",&lcase,&ucase))
end

View file

@ -0,0 +1,4 @@
toupper 'alphaBETA'
ALPHABETA
tolower 'alphaBETA'
alphabeta

View file

@ -0,0 +1,2 @@
upper=: {&((65+i.26) +&32@[} i.256)&.(a.&i.)
lower=: {&((97+i.26) -&32@[} i.256)&.(a.&i.)

View file

@ -0,0 +1,4 @@
upper 'alphaBETA'
ALPHABETA
lower 'alphaBETA'
alphabeta

View file

@ -0,0 +1 @@
String string = "alphaBETA".toUpperCase();

View file

@ -0,0 +1 @@
String string = "alphaBETA".toLowerCase();

Some files were not shown because too many files have changed in this diff Show more