Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,2 @@
Str : String := "Hello World";
Length : constant Natural := Str'Size / 8;

View file

@ -0,0 +1,6 @@
Latin_1_Str : String := "Hello World";
UCS_16_Str : Wide_String := "Hello World";
Unicode_Str : Wide_Wide_String := "Hello World";
Latin_1_Length : constant Natural := Latin_1_Str'Length;
UCS_16_Length : constant Natural := UCS_16_Str'Length;
Unicode_Length : constant Natural := Unicode_Str'Length;

View file

@ -0,0 +1,6 @@
import ballerina/io;
public function main() {
string s = "møøse";
io:println(s.length());
}

View file

@ -0,0 +1,10 @@
import ballerina/io;
function byteLen(string s) returns int {
return s.toBytes().length();
}
public function main() {
string s = "møøse";
io:println(byteLen(s));
}

View file

@ -0,0 +1 @@
FUNCTION BYTE-LENGTH(str)

View file

@ -0,0 +1 @@
LENGTH OF str

View file

@ -0,0 +1 @@
FUNCTION LENGTH-AN(str)

View file

@ -0,0 +1 @@
FUNCTION LENGTH(str)

View file

@ -1,4 +1,4 @@
text moose = "møøse"
text unicode = "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
text jose = "J" + 0U0332 + "o" + 0U0332 + "s" + 0U0332 + "e" + 0U0301 + 0U0332
text emoji = "𠇰😈🎶🔥é-"
text moose "møøse"
text unicode "𝔘𝔫𝔦𝔠𝔬𝔡𝔢"
text jose "J" + 0U0332 + "o" + 0U0332 + "s" + 0U0332 + "e" + 0U0301 + 0U0332
text emoji "𠇰😈🎶🔥é-"

View file

@ -0,0 +1,2 @@
(length "hello")
;; => 5

View file

@ -0,0 +1,2 @@
(string-bytes "\u1D518\u1D52B\u1D526")
;; => 12

View file

@ -0,0 +1,7 @@
(let ((str (apply 'string
(mapcar (lambda (c) (decode-char 'ucs c))
'(#x1112 #x1161 #x11ab #x1100 #x1173 #x11af)))))
(list (length str)
(string-bytes str)
(string-width str)))
;; => (6 18 4) ;; in emacs 23 up

View file

@ -0,0 +1 @@
print(1,length("Hello World"))

View file

@ -0,0 +1,3 @@
pub fn main() {
echo string.length("𝔘𝔫𝔦𝔠𝔬𝔡𝔢")
}

View file

@ -3,26 +3,19 @@ module String_length {
Print Len(A$) = 9 ' true Utf-16LE
Print Len.Disp(A$) = 4 \\ display length
Buffer Clear Mem as Byte*100
\\ Write at memory at offset 0 or address Mem(0)
Return Mem, 0:=A$
Print Eval$(Mem, 0, 18)
For i=0 to 17 step 2
\\ print hex value and character
Hex Eval(Mem, i as integer), ChrCode$(Eval(Mem, i as integer))
Buffer Mem2 as Integer*50
Mem[0]=A$
Print Eval$(Mem, 0, 18) ' 18 bytes from Mem[0] as a string
Mem2[0]=Mem
For i=0 to 8
Hex Mem2[i], ChrCode$(Mem2[i])
Next i
Document B$=A$
\\ encode to utf-8 with BOM (3 bytes 0xEF,0xBB,0xBF)
Save.Doc B$, "Checklen.doc", 2
Print Filelen("Checklen.doc")=17
\\ So length is 14 bytes + 3 the BOM
Mem=Buffer("Checklen.doc")
Print len(Mem)=17 // len works for buffers too - unit byte
// version 12 can handle strings without suffix $
C=eval$(mem, 3, 14) // from 4th byte get 14 bytes in a string
Print len(C)*2=14 ' bytes // len()) for strings return double type of words (can return 0.5)
C=string$(C as utf8dec) ' decode bytes from utf8 to utf16LE
Print len(C)=9, C=A$, Len.Disp(C)=4
Print C
Report 2, C // proportional print on console - for text center justified rendering (2 - center)
// Check as UTF8 (UTFEnc and UTF8Dec are selections for string$())
Print len(string$(A$ as UTF8Enc))*2=14 ' bytes
Locale 1033
// to ANSI and back to UTF16LE (destructive)
Print chr$(str$(A$))="J_o_s_e´_" ' true
Print A$;POS=4 ' J̲o̲s̲é̲True
Print String$(A$ as Json)="J\u0332o\u0332s\u0332e\u0301\u0332" ' True
}
String_length

View file

@ -0,0 +1,10 @@
REM https://github.com/Eva-Broccoli/OPL-Rosetta-Code/blob/main/Strlngth.opl
REM Strings are stored with one character per byte, with a leading byte containing the string length, thus byte length is character length plus one byte.
PROC main:
LOCAL s$(100)
PRINT "Please enter a string."
INPUT s$
PRINT "Character length:",LEN(s$)
PRINT "Byte length:",LEN(s$)+1
GET
ENDP

View file

@ -0,0 +1,2 @@
$s = "Hëlló Wørłð"
$s.Length

View file

@ -0,0 +1,2 @@
$s = "Hëlló Wørłð"
[System.Text.Encoding]::Unicode.GetByteCount($s)

View file

@ -0,0 +1 @@
[System.Text.Encoding]::UTF8.GetByteCount($s)

View file

@ -0,0 +1,110 @@
# riscv assembly raspberry pico2 rp2350
# program lenstring.s
# connexion putty com3
/*********************************************/
/* CONSTANTES */
/********************************************/
/* for this file see risc-v task include a file */
.include "../../constantesRiscv.inc"
.equ BUFFERSIZE, 255
/*******************************************/
/* INITIALED DATAS */
/*******************************************/
.data
szMessStart: .asciz "Program riscv start.\r\n"
szMessEndOk: .asciz "Program riscv end OK.\r\n"
szCariageReturn: .asciz "\r\n"
szMessLenString: .asciz "The lenght of string "
szMessLenString1: .asciz " is "
szString1: .asciz "Apple"
szString2: .asciz "Orange"
.align 2
/*******************************************/
/* UNINITIALED DATA */
/*******************************************/
.bss
sConvArea: .skip 24
.align 2
/**********************************************/
/* SECTION CODE */
/**********************************************/
.text
.global main
main:
call stdio_init_all # général init
1: # start loop connexion
li a0,0 # raz argument register
call tud_cdc_n_connected # waiting for USB connection
beqz a0,1b # return code = zero ?
la a0,szMessStart # message address
call writeString # display message
la s0,szString1 # adresse string 1
mv a0,s0
call stringlength # len string
la a1,sConvArea
call conversion10 # call decimal conversion
la a0,szMessLenString
call writeString
mv a0,s0
call writeString
la a0,szMessLenString1
call writeString
la a0,sConvArea # display result message
call writeString
la a0,szCariageReturn
call writeString
la s0,szString2 # adresse string 2
mv a0,s0
call stringlength # len string
la a1,sConvArea
call conversion10 # call decimal conversion
la a0,szMessLenString
call writeString
mv a0,s0
call writeString
la a0,szMessLenString1
call writeString
la a0,sConvArea # display result message
call writeString
la a0,szCariageReturn
call writeString
la a0,szMessEndOk # message address
call writeString # display message
call getchar
100: # final loop
j 100b
/***************************************************/
/* compute string length */
/***************************************************/
# a0 contains string e
# a0 return length
stringlength:
addi sp, sp, -4 # reserve stack
sw ra, 0(sp) # save registers @ save registers
li t1,-1 # init counter
1: # loop
addi t1,t1,1 # increment counter
add t0,a0,t1 # compute byte address
lbu t2,(t0) # load byte string
bnez t2,1b # zero final ?
mv a0,t1 #return length
100:
lw ra, 0(sp)
addi sp, sp, 4
ret
/************************************/
/* file include Fonctions */
/***********************************/
/* for this file see risc-v task include a file */
.include "../../includeFunctions.s"

View file

@ -0,0 +1 @@
Js.String2.length("abcd") == 4

View file

@ -0,0 +1,5 @@
;; r2
length? "møøse"
;; r3
length? to-binary "møøse"

View file

@ -0,0 +1,2 @@
;; r3
length? "møøse"

View file

@ -0,0 +1 @@
length? "Hello"

View file

@ -0,0 +1 @@
LenB(string|varname)

View file

@ -0,0 +1 @@
Len(string|varname)

View file

@ -0,0 +1,60 @@
%macro prolog 1
push rbp
mov rbp, rsp
sub rsp, %1
%endmacro
%macro epilog 1
add rsp, %1
pop rbp
%endmacro
%macro xcall 1
call [rel %1 wrt ..got]
%endmacro
%macro xlea 2
lea %1, [rel %2]
%endmacro
extern printf
extern exit
section .text
global xstrlen
xstrlen:
push rbp
mov rbp, rsp
mov rax, rdi ;; Change this to RCX and it works on windoze ABI.
mov rsi, rax
xor rbx, rbx
__xlen_count:
cmp byte [rsi+rbx], 0
je __xlen_exit
inc rbx
jne __xlen_count
__xlen_exit:
mov rax, rbx
pop rbp
ret
;; This will not work on Windoze. Change the macro LEA and CALL maybe.
global main
main:
prolog 4*8
xlea rdi, s1
call xstrlen
xlea rsi, rax ;;RDX - windoze ABI
xlea rdi, p_tpl ;;RCX - windoze ABI
xcall printf
xor edi, edi
xcall exit
epilog 4*8 ;;Never gets here but w/e.
ret
section .rodata
s1 db "Good luck getting the stuff below this to assemble.",13,10,0
p_tpl db "len: %i",13,10,0

View file

@ -0,0 +1,182 @@
; compute string length
; assembly X86 window
; download and install visual studio 2022 free site microsoft
; search and open X64 native tools command prompt
; compil and link program with this command :
; ml64 lenString.asm /link /ENTRY:main /SUBSYSTEM:console kernel32.lib user32.lib Shell32.lib
; this program respects the 64-bit calling convention :
; registers arguments : rcx rdx r8 r9 and stack
; registers saved : rbx,rbp,rdi,rsi, r12-r15
; ATTENTION les registres rax,rcx,rdx,r8-r11 peuvent être
; perdus lors d'un appel de fonction
;*********************************
; constantes
;*********************************
STD_OUTPUT_HANDLE equ -11
BUFFERSIZE equ 200
;*********************************
; macros
;*********************************
;for this file, see task include a file for X86-64 language
include macrosInclude.asm
;*********************************
; user data
;*********************************
.data
szMesslength db "The lenght of string ",0
LGMESSLEN equ $ - szMesslength - 1
szMesslength1 db " is ",0
LGMESSLEN1 equ $ - szMesslength1 - 1
szCarriageReturn db 10,0
szString1 db "Apple",0
LGSTRING1 equ $ - szString1 - 1
szString2 db "Orange",0
LGSTRING2 equ $ - szString2 - 1
align 8
hConsole dq 0
sConvArea db 24 dup (0)
sBuffer db BUFFERSIZE dup (' ')
;*********************************
; user code fonction principale
;*********************************
.code
extern WriteFile : proc, GetStdHandle : proc, ExitProcess : proc
extern GetLastError : proc
main PROC public
displayLib "Program X86-64 start."
mov rcx, offset szMesslength
mov rdx,LGMESSLEN
call afficherConsole
mov rcx, offset szString1
mov rdx,LGSTRING1
call afficherConsole
mov rcx, offset szMesslength1
mov rdx,LGMESSLEN1
call afficherConsole
mov rcx, offset szString1
call lenString ; compute length
mov rcx,rax
mov rdx, offset sConvArea
call conversion10
mov rdx,rax ; result size
mov rcx, offset sConvArea
call afficherConsole
mov rcx, offset szCarriageReturn
mov rdx,1
call afficherConsole
mov rcx, offset szMesslength
mov rdx,LGMESSLEN
call afficherConsole
mov rcx, offset szString1
mov rdx,LGSTRING1
call afficherConsole
mov rcx, offset szMesslength1
mov rdx,LGMESSLEN1
call afficherConsole
mov rcx, offset szString1
call lenString2 ; other compute methode
mov rcx,rax
mov rdx, offset sConvArea
call conversion10
mov rdx,rax ; result size
mov rcx, offset sConvArea
call afficherConsole
mov rcx, offset szCarriageReturn
mov rdx,1
call afficherConsole
mov rcx, offset szMesslength
mov rdx,LGMESSLEN
call afficherConsole
mov rcx, offset szString1
mov rdx,LGSTRING1
call afficherConsole
mov rcx, offset szMesslength1
mov rdx,LGMESSLEN1
call afficherConsole
mov rcx,LGSTRING1 ; direct value for static string
mov rdx, offset sConvArea
call conversion10
mov rdx,rax ; result size
mov rcx, offset sConvArea
call afficherConsole
mov rcx, offset szCarriageReturn
mov rdx,1
call afficherConsole
mov rcx, offset szMesslength
mov rdx,LGMESSLEN
call afficherConsole
mov rcx, offset szString2
mov rdx,LGSTRING2
call afficherConsole
mov rcx, offset szMesslength1
mov rdx,LGMESSLEN1
call afficherConsole
mov rcx, offset szString2
call lenString ; compute length
mov rcx,rax
mov rdx, offset sConvArea
call conversion10
mov rdx,rax ; result size
mov rcx, offset sConvArea
call afficherConsole
mov rcx, offset szCarriageReturn
mov rdx,1
call afficherConsole
finProgramme:
displayLib "Program end."
sub rsp,28h
mov rcx,0 ; return code
call ExitProcess
main ENDP
;***************************************************
;compute string length
;****************************************************
; rcx : string address
lenString PROC
mov rax,0 ; counter init
@B1:
mov dl,[rax+rcx] ; load one byte of string
cmp dl,0 ; zero final ?
je @B2 ; yes -> end
inc rax ; increment counter
jmp @B1 ; and loop
@B2:
ret
lenString ENDP
;***************************************************
;compute string length other method
;****************************************************
; rcx : string address
lenString2 PROC
push rdi
xor rax,rax ; raz rax
mov rdi,rcx ; move string address
mov rcx,-1 ; init rcx
cld ; direction flag to zero
repne scasb ; repeat comparaison one character
not rcx ; ???
dec rcx ; ???
mov rax,rcx ; return result
pop rdi
ret
lenString2 ENDP
;for this file, see task include a file for X86-64 language
include routinesInclude.asm
end