-
Notifications
You must be signed in to change notification settings - Fork 2
/
xivid_notes.txt
executable file
·11287 lines (10191 loc) · 530 KB
/
xivid_notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--------------------------------
Xivid notities
--------------------------------
[Reeksen en positionering]
$ xidel -se 'join((1,2,3))'
1 2 3
$ xidel -se 'join(1 to 10)'
1 2 3 4 5 6 7 8 9 10
$ xidel -se 'join(x:cps((65,66,67)))'
A B C
$ xidel -se 'join(x:cps(65 to 74))'
A B C D E F G H I J
$ xidel -se 'x:cps(65 to 74)[1]'
$ xidel -se 'head(x:cps(65 to 74))'
A
$ xidel -se 'x:cps(65 to 74)[last()]'
J
$ xidel -se 'join(x:cps(66 to 74))'
$ xidel -se 'join(x:cps(65 to 74)[position() gt 1])'
$ xidel -se 'join(x:cps(65 to 74)[position() = 2 to last()])'
$ xidel -se 'join(x:cps(65 to 74)[position() ne 1])'
$ xidel -se 'join(tail(x:cps(65 to 74)))'
$ xidel -se 'join(subsequence(x:cps(65 to 74),2))'
B C D E F G H I J
$ xidel -se 'join(x:cps(65 to 73))'
$ xidel -se 'join(x:cps(65 to 74)[position() lt last()])'
$ xidel -se 'join(x:cps(65 to 74)[position() = 1 to last() - 1])'
$ xidel -se 'join(x:cps(65 to 74)[position() ne last()])'
$ xidel -se 'join(let $a:=x:cps(65 to 74) return subsequence($a,1,count($a) - 1))'
A B C D E F G H I
$ xidel -se 'join(x:cps((65 to 74)[. ne 69]))'
$ xidel -se 'join(x:cps((65 to 68,70 to 74)))'
$ xidel -se 'join(x:cps(65 to 74)[position() ne 5])'
$ xidel -se 'join(x:cps(65 to 74)[position() = (1 to 4,6 to last())])'
$ xidel -se 'join(remove(x:cps(65 to 74),5))'
A B C D F G H I J
$ xidel -se 'join(x:cps(68 to 71))'
$ xidel -se 'join(x:cps(65 to 74)[position() = 4 to 7])'
$ xidel -se 'join(x:cps(65 to 74)[position() gt 3 and position() lt 8])'
$ xidel -se 'join(x:cps(65 to 74)[position() gt 3][position() lt 5])'
$ xidel -se 'join(subsequence(x:cps(65 to 74),4,4))'
D E F G
$ xidel -se 'join(x:cps((65,67,69,71,73)))'
$ xidel -se 'join(x:cps((65 to 74)[. mod 2 eq 1]))'
$ xidel -se 'join(x:cps(for $x in 65 to 74 where $x mod 2 eq 1 return $x))'
$ xidel -se 'join(x:cps(65 to 74)[position() mod 2 eq 1])'
$ xidel -se 'join(for $x at $i in x:cps(65 to 74) where $i mod 2 eq 1 return $x)'
A C E G I
$ xidel -se 'join(x:cps((66,68,70,72,74)))'
$ xidel -se 'join(x:cps((65 to 74)[. mod 2 eq 0]))'
$ xidel -se 'join(x:cps(for $x in 65 to 74 where $x mod 2 eq 0 return $x))'
$ xidel -se 'join(x:cps(65 to 74)[position() mod 2 eq 0])'
$ xidel -se 'join(for $x at $i in x:cps(65 to 74) where $i mod 2 eq 0 return $x)'
B D F H J
$ xidel -se 'join(x:cps(reverse(65 to 74)))'
$ xidel -se 'join(x:cps(for $x in 65 to 74 order by $x descending return $x))'
$ xidel -se 'join(reverse(x:cps(65 to 74)))'
$ xidel -se 'join(for $x at $i in x:cps(65 to 74) order by $i descending return $x)'
J I H G F E D C B A
$ xidel -se 'join(x:cps((73,69,65)))'
$ xidel -se 'join(x:cps(reverse(65 to 74)[. mod 4 eq 1]))'
$ xidel -se 'join(x:cps(for $x in 65 to 74 where $x mod 4 eq 1 order by $x descending return $x))'
$ xidel -se 'join(reverse(x:cps(65 to 74)[position() mod 4 eq 1]))'
$ xidel -se 'join(for $x at $i in x:cps(65 to 74) where $i mod 4 eq 1 order by $i descending return $x)'
I E A
================================================================================================
[JSON filtering and selection]
$ xidel -se '
let $a:={"a":1,"b":2} return (
{"foo":{"bar":$a/c}},
{"foo":{"bar":$a/c}[bar]},
{"foo":{"bar1"?:$a/a,"bar2"?:$a/b,"bar3"?:$a/c}},
{"foo":{"bar1"?:$a/a,"bar2"?:$a/c}},
{"foo":{"bar"?:$a/c}},
{"foo":array{{"bar":$a/a},{"bar":$a/b},{"bar":$a/c}[bar]}},
{"foo":array{{"bar":$a/a},{"bar":$a/c}[bar]}},
{"foo":array{{"bar":$a/c}[bar]}},
{"foo":({"bar":$a/a},{"bar":$a/b},{"bar":$a/c}[bar])},
{"foo":({"bar":$a/a},{"bar":$a/c}[bar])},
{"foo":({"bar":$a/c}[bar])},
{"foo":({"bar":$a/a},{"bar":$a/b},{"bar":$a/c}[bar]) ! [.]},
{"foo":({"bar":$a/a},{"bar":$a/c}[bar]) ! [.]},
{"foo":({"bar":$a/c}[bar]) ! [.]},
{"foo":let $b:=({"bar":$a/a},{"bar":$a/b},{"bar":$a/c}[bar]) return array{$b}},
{"foo":let $b:=({"bar":$a/a},{"bar":$a/c}[bar]) return array{$b}},
{"foo":let $b:=({"bar":$a/c}[bar]) return array{$b}},
{"foo":let $b:=({"bar":$a/a},{"bar":$a/b},{"bar":$a/c}[bar]) return array{$b}[exists($b)]},
{"foo":let $b:=({"bar":$a/a},{"bar":$a/c}[bar]) return array{$b}[exists($b)]},
{"foo":let $b:=({"bar":$a/c}[bar]) return array{$b}[exists($b)]}
)
' --output-json-indent=compact
{"foo": {"bar": null}}
{"foo": null} # [bar] evalueert naar null, waardoor het hele object verdwijnt.
{"foo": {"bar1": 1, "bar2": 2}} # ? is "optional pair".
{"foo": {"bar1": 1}}
{"foo": {}} # Geen attribute-value-pair? Dan krijg je een leeg object.
{"foo": [{"bar": 1}, {"bar": 2}]}
{"foo": [{"bar": 1}]}
{"foo": []} # Met blokhaken krijg je zonder één object een lege array.
{"foo": [{"bar": 1}, {"bar": 2}]} # Met haakjes evalueert de reeks automatisch tot array.
{"foo": {"bar": 1}} # De reeks, uiteindelijk één object, blijft ook een object.
{"foo": null}
{"foo": [[{"bar": 1}], [{"bar": 2}]]} # Elk object van de reeks wordt een array en dit evalueert tot weer een array.
{"foo": [{"bar": 1}]}
{"foo": null}
{"foo": [{"bar": 1}, {"bar": 2}]} # De hele reeks wordt een array.
{"foo": [{"bar": 1}]}
{"foo": []} # Zonder te controleren of $b minimaal één object heeft krijg je weer een lege array.
{"foo": [{"bar": 1}, {"bar": 2}]}
{"foo": [{"bar": 1}]}
{"foo": null} # De enige manier voor de eis "Eén of meerdere objecten? Array. Nul objecten? null.
------------------------------------------------------------------------------------------------
$ xidel -se '
let $a:={"a":1,"b":2},
$b:={"a":"1","b":"2"}
return (
{"foo":$a[b]/{"bar":b}},
{"foo":$a[exists(b)]/{"bar":b}},
{"foo":$b[b]/{"bar":b}},
{"foo":$b[exists(b)]/{"bar":b}},
{"foo":$a[c]/{"bar":c}},
{"foo"?:$a[c]/{"bar":c}},
map:merge({"foo":$a[c]/{"bar":c}}[foo]),
map:merge(let $val:=$a[c]/{"bar":c} where exists($val) return {"foo":$val})
)
' --output-json-indent=compact
{"foo": null} # $a[b] evalueert naar $a[2], maar er is geen 2e object, dus krijg je null.
{"foo": {"bar": 2}} # Als de waarde van het attribuut dat je checkt een integer is, dan is exists() vereist.
{"foo": {"bar": "2"}} # $b/b is een string en dus is exists() niet vereist.
{"foo": {"bar": "2"}}
{"foo": null}
{}
{}
{}
------------------------------------------------------------------------------------------------
$ echo '{"a":null}' | xidel -se '
$json/join((exists(a),a)),
jn:parse-json($raw)/join((exists(a),a)),
parse-json($raw)/join((exists(a),a))
'
false
true null
false
$ echo '{"a":null}' | xidel --json-mode=deprecated -se '
$json/join((exists(a),a)),
jn:parse-json($raw)/join((exists(a),a)),
parse-json($raw)/join((exists(a),a))
'
true null
true null
false
$ echo '{"a":null,"b":"foo"}' | xidel -se '$json/concat((a,b),"bar")'
$ echo '{"a":null,"b":"foo"}' | xidel -se 'parse-json($raw)/concat((a,b),"bar")'
$ echo '{"a":null,"b":"foo"}' | xidel -se 'jn:parse-json($raw)/concat((a,b)[.],"bar")'
$ echo '{"a":null,"b":"foo"}' | xidel --json-mode=deprecated -se '$json/concat((a,b)[.],"bar")'
$ echo '{"a":null,"b":"foo"}' | xidel --json-mode=deprecated -se 'parse-json($raw)/concat((a,b),"bar")'
foobar
$ echo '{"a":null,"b":"foo"}' | xidel --json-mode=deprecated -se '$json/concat((a,b),"bar")'
$ echo '{"a":null,"b":"foo"}' | xidel -se 'jn:parse-json($raw)/concat((a,b),"bar")'
Error:
err:XPTY0004: Invalid conversion from (null, "foo") to type singleton
------------------------------------------------------------------------------------------------
$ xidel -se 'let $a:={"a":1,"b":{"c":2}} return $a[b]/b' --printed-json-format=compact # xidel-0.9.9-7580-9cac3c1
{"c": 2}
$ xidel -se 'let $a:={"a":1,"b":{"c":2}} return $a[b]/b' --printed-json-format=compact # xidel-0.9.9-7622-1650cd0
Error:
err:FORG0006: Object cannot be used as boolean:
{"c": 2}
$ xidel -se 'let $a:={"a":1,"b":{"c":2}} return $a[exists(b)]/b' --printed-json-format=compact # xidel-0.9.9-7622-1650cd0
{"c": 2}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$ xidel -se 'let $a:=array{{"a":1},{"b":2}} return if ($a(2)) then $a(2) else ()' --printed-json-format=compact # xidel-0.9.9-7580-9cac3c1
{"b": 2}
$ xidel -se 'let $a:=array{{"a":1},{"b":2}} return if ($a(2)) then $a(2) else ()' --printed-json-format=compact # xidel-0.9.9-7622-1650cd0
Error:
err:FORG0006: Object cannot be used as boolean:
{"b": 2}
$ xidel -se 'let $a:=array{{"a":1},{"b":2}} return if (exists($a(2))) then $a(2) else ()' --printed-json-format=compact # xidel-0.9.9-7622-1650cd0
{"b": 2}
================================================================================================
[Base conversions]
Decimal (Base 10) 31 = (3*10^1)+(1*10^0) = 30+1 = 31
Binary (Base 2) 11111 = (1*2^4)+(1*2^3)+(1*2^2)+(1*2^1)+(1*2^0) = 16+8+4+2+1 = 31
Hexadecimal (Base 16) 1F = (1*16^1)+(15*16^0) = 16+15 = 31
Dec to Bin/Hex:
$ xidel -se 'x:integer-to-base(31,2)'
11111
$ xidel -se 'x:integer-to-base(31,16)'
1F
Bin/Hex to Dec:
$ xidel -se 'x:integer("11111",2)'
$ xidel -se 'x:integer("0b11111")'
$ xidel -se 'x:integer("1F",16)'
$ xidel -se 'x:integer("0x1F")'
31
Bin to Hex:
$ xidel -se 'x:integer-to-base(x:integer("11111",2),16)'
$ xidel -se 'x:integer-to-base(x:integer("0b11111"),16)'
1F
Hex to Bin:
$ xidel -se 'x:integer-to-base(x:integer("1F",16),2)'
$ xidel -se 'x:integer-to-base(x:integer("0x1F"),2)'
11111
------------------------------------------------------------------------------------------------
Unsigned (32bit) Hex to Dec:
xidel -se "x:integer('0xffffff88')"
4294967176
Signed (32bit) Hex to Dec:
https://www.digital-detective.net/manual-identification-of-suspect-computer-time-zone-2/
http://core.ecu.edu/csci/wirthj/Basen/signBin-c.html
https://stackoverflow.com/q/5826818
https://stackoverflow.com/q/33629416
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Check of de hoeveelheid bits groter is dan 31:
- Tel het aantal bits.
$ xidel -se 'x:integer-to-base(x:integer("0xffffff88"),2)'
11111111111111111111111110001000
$ xidel -se 'string-length(x:integer-to-base(x:integer("0xffffff88"),2))'
32
- Converteer als unsigned 32bit Hex en trek daar 2^(aantal bits) van af.
$ xidel -se 'math:pow(2,string-length(x:integer-to-base(x:integer("0xffffff88"),2)))'
4.294967296E9
$ xidel -se 'integer(math:pow(2,string-length(x:integer-to-base(x:integer("0xffffff88"),2))))'
4294967296
$ xidel -se 'let $a:=x:integer("0xffffff88") return $a - integer(math:pow(2,string-length(x:integer-to-base($a,2))))'
-120
- Dit geldt alleen voor 0x80000000 en hoger. Converteer 0x7fffffff en lager als unsigned 32bit Hex!
$ xidel -se 'x:integer-to-base(x:integer("0x80000000"),2)'
10000000000000000000000000000000
$ xidel -se 'x:integer-to-base(x:integer("0x7fffffff"),2)'
1111111111111111111111111111111
$ xidel -se 'let $a:=x:integer("0x80000000"),$b:=x:integer-to-base($a,2) return if (string-length($b) gt 31) then $a - integer(math:pow(2,string-length($b))) else $a'
-2147483648
$ xidel -se 'let $a:=x:integer("0x7fffffff"),$b:=x:integer-to-base($a,2) return if (string-length($b) gt 31) then $a - integer(math:pow(2,string-length($b))) else $a'
2147483647 # 2^31
$ xidel -se 'let $a:=x:integer("0xffffff88"),$b:=x:integer-to-base($a,2) return if (string-length($b) gt 31) then $a - integer(math:pow(2,string-length($b))) else $a'
-120
$ time xidel -se 'declare function local:shex-to-dec($shex as string) as integer {let $a:=x:integer($shex),$b:=x:integer-to-base($a,2) return if (string-length($b) gt 31) then $a - integer(math:pow(2,string-length($b))) else $a}; ((1 to 100000) ! local:shex-to-dec("0xffffff88"))[1]'
-120
real 0m30.359s
user 0m0.015s
sys 0m0.015s
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Check of de decimale waarde groter is dan 2^31:
- Tel het aantal bits.
$ xidel -se '(string-length("0xffffff88") - 2) * 4'
$ xidel -se 'string-length("ffffff88") * 4'
32
x4, want F_16 is 1111_2 (4 bits):
$ xidel -se 'x:integer-to-base(x:integer("0xf"),2)'
1111
- Converteer als unsigned 32bit Hex en trek daar 2^(aantal bits) van af.
$ xidel -se 'math:pow(2,(string-length("0xffffff88") - 2) * 4)'
4.294967296E9
$ xidel -se 'integer(math:pow(2,(string-length("0xffffff88") - 2) * 4))'
4294967296
$ xidel -se 'x:integer("0xffffff88") - integer(math:pow(2,(string-length("0xffffff88") - 2) * 4))'
-120
- Dit geldt alleen voor 0x80000000 en hoger. Converteer 0x7fffffff en lager als unsigned 32bit Hex!
$ xidel -se 'x:integer("0x80000000")'
2147483648
$ xidel -se 'integer(math:pow(2,(string-length("0x80000000") - 2) * 4 - 1))'
2147483648 # 2^31
$ xidel -se 'integer(math:pow(2,(string-length("0x80000000") - 2) * 4)) div 2'
2147483648
$ xidel -se 'let $a:=x:integer("0x80000000"),$b:=integer(math:pow(2,(string-length("0x80000000") - 2) * 4)) return if ($a gt $b div 2) then $a - $b else $a'
-2147483648
$ xidel -se 'let $a:=x:integer("0x7fffffff"),$b:=integer(math:pow(2,(string-length("0x7fffffff") - 2) * 4)) return if ($a gt $b div 2) then $a - $b else $a'
2147483647
$ xidel -se 'let $a:=x:integer("0xffffff88"),$b:=integer(math:pow(2,(string-length("0xffffff88") - 2) * 4)) return if ($a gt $b div 2) then $a - $b else $a'
-120
$ time xidel -se 'declare function local:shex-to-dec($shex as string) as integer {let $a:=x:integer($shex),$b:=integer(math:pow(2,(string-length($shex) - 2) * 4)) return if ($a gt $b div 2) then $a - $b else $a}; ((1 to 100000) ! local:shex-to-dec("0xffffff88"))[1]'
-120
real 0m4.813s # Veel snellere methode!
user 0m0.015s
sys 0m0.015s
declare function xivid:shex-to-dec($shex as string) as integer {
let $a:=x:integer($shex),
$b:=integer(math:pow(2,(string-length($shex) - 2) * 4))
return
if ($a gt $b div 2) then $a - $b else $a
};
------------------------------------------------------------------------------------------------
Genereer een willekeurig 128bit hexadecimaal getal:
$ xidel -se 'join((1 to 32))'
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
$ xidel -se 'random-seed(),join((1 to 32) ! random(16))'
8 5 3 4 15 0 13 7 15 2 7 3 13 1 10 8 6 7 11 5 5 8 9 3 11 5 5 1 10 8 0 1
$ xidel -se 'random-seed(),join((1 to 32) ! x:integer-to-base(random(16),16))'
8 5 3 4 F 0 D 7 F 2 7 3 D 1 A 8 6 7 B 5 5 8 9 3 B 5 5 1 A 8 0 1
$ xidel -se 'random-seed(),string-join((1 to 32) ! x:integer-to-base(random(16),16))'
8534F0D7F273D1A867B55893B551A801
------------------------------------------------------------------------------------------------
Base64:
https://en.wikipedia.org/wiki/Base64
$ xidel -se 'string-to-base64Binary("Xivid")'
WGl2aWQ=
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
String to Base64 (zonder string-to-base64Binary() ):
----------------------------------------------------------------
Base64 tekens:
$ xidel -se 'string-join(x:cps((65 to 90,97 to 122,48 to 57,43,47)))'
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
| 65 t/m 90 || 97 t/m 122 ||48 t/m57||43,47 # Codepoints in ASCII tabel.
0 63 # 64 tekens, range: 0-63.
Principe:
X i v i d # van teken
88 105 118 105 100 # naar codepoint/decimaal
01011000 01101001 01110110 01101001 01100100 # naar binair
010110 000110 100101 110110 011010 010110 0100[00] # opdelen in groepjes van 6 bits
22 6 37 54 26 22 16 # naar decimaal/codepoint
W G l 2 a W Q = # naar base64 met eventuele padding
----------------------------------------------------------------
$ xidel -se 'join(string-to-codepoints("Xivid"))'
$ xidel -se 'join(x:cps("Xivid"))'
88 105 118 105 100
$ xidel -se 'join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000"))'
01011000 01101001 01110110 01101001 01100100
$ xidel -se 'string-join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000"))'
0101100001101001011101100110100101100100
Deze string moet opgedeeld worden in substrings met een lengte van 6 tekens.
$ xidel -se 'let $bin:=string-join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000")) return join((1 to string-length($bin))[. mod 6 eq 1] ! substring($bin,.,6))'
$ xidel -se 'join(extract(string-join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000")),".{6}|.+",0,"*"))'
010110 000110 100101 110110 011010 010110 0100
De binaire getallen dienen altijd 6 bits te bevatten.
$ xidel -se 'join(extract(string-join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000")),".{6}|.+",0,"*") ! substring(.||"00000",1,6))'
010110 000110 100101 110110 011010 010110 010000
De extra nullen worden later als padding (=) toegevoegd. 00 wordt =, 0000 wordt ==.
$ xidel -se 'join(extract(string-join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000")),".{6}|.+",0,"*") ! (substring(.||"00000",1,6),.[string-length() ne 6]))'
010110 000110 100101 110110 011010 010110 010000 0100
$ xidel -se 'join(extract(string-join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000")),".{6}|.+",0,"*") ! (x:integer(substring(.||"00000",1,6),2),.[string-length() ne 6] ! (6 mod string-length() div 2) ! "="))'
22 6 37 54 26 22 16 =
$ xidel -se 'let $base64:=x:cps((65 to 90,97 to 122,48 to 57,43,47)) return string-join(for $x in extract(string-join(x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000")),".{6}|.+",0,"*") return ($base64[x:integer(substring($x||"00000",1,6),2) + 1],$x[string-length() ne 6] ! (6 mod string-length() div 2) ! "="))'
WGl2aWQ=
let $base64:=x:cps((65 to 90,97 to 122,48 to 57,43,47)) return
string-join(
for $x in extract(
string-join(
x:cps("Xivid") ! format-integer(x:integer-to-base(.,2),"00000000")
),
".{6}|.+",0,"*"
) return (
$base64[x:integer(substring($x||"00000",1,6),2) + 1],
$x[string-length() ne 6] ! (6 mod string-length() div 2) ! "="
)
)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Base64 to string:
$ xidel -se 'binary-to-string(base64Binary("WGl2aWQ="))'
Xivid
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Base64 to file:
$ xidel -se 'file:write-binary("nl.png",base64Binary("iVBORw0KGgoAAAANSUhEUgAAABIAAAAMCAIAAADgcHrrAAAAG0lEQVQoz2P4z8BABmIYGtrIAkND21CJAjIQAF2WZqj5EZlfAAAAAElFTkSuQmCC"))'
File to Base64:
$ xidel -se 'file:read-binary("nl.png")' # Nederlandse vlag van 18 bij 12 pixels.
iVBORw0KGgoAAAANSUhEUgAAABIAAAAMCAIAAADgcHrrAAAAG0lEQVQoz2P4z8BABmIYGtrIAkND21CJAjIQAF2WZqj5EZlfAAAAAElFTkSuQmCC
File to Base64 (html):
$ xidel -se '(<img src="data:image/png;base64,{file:read-binary("nl.png")}"/>)' --output-node-format=html
$ xidel -s --xquery '<img src="data:image/png;base64,{file:read-binary("nl.png")}"/>' --output-node-format=html
$ xidel -se 'element img {attribute src {"data:image/png;base64,"||file:read-binary("nl.png")}}' --output-node-format=html
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAMCAIAAADgcHrrAAAAG0lEQVQoz2P4z8BABmIYGtrIAkND21CJAjIQAF2WZqj5EZlfAAAAAElFTkSuQmCC">
================================================================================================
[Exclusieve disjunctie (exclusive or / xor)]
Zolang Xidel de "EXPath Binary Module" (met bin:xor()) niet aan boord heeft is een zelfgemaakte functie nodig.
Zie https://github.com/benibela/xidel/issues/54.
$ echo $((33 ^ 73))
104
$ xidel -se 'let $a:=33,$b:=73 return system(`bash -c "printf $(({$a} ^ {$b}))"`)'
104
33_10 = 0100001_2
73_10 = 1001001_2
------- XOR
104_10 = 1101000_2 # Output is alleen 1 als input 0 én 1 of 1 én 0 is.
$ xidel -se '(33,73) ! x:integer-to-base(.,2)'
100001
1001001
$ xidel -se '(33,73) ! x:integer-to-base(.,2) ! string-length()'
6
7
$ xidel -se 'let $bin:=(33,73) ! x:integer-to-base(.,2) return max($bin ! string-length())'
7
$ xidel -se 'let $bin:=(33,73) ! x:integer-to-base(.,2),$len:=max($bin ! string-length()) return $bin ! format-integer(.,string-join((1 to $len) ! 0))'
0100001
1001001
$ xidel -se 'let $bin:=(33,73) ! x:integer-to-base(.,2),$len:=max($bin ! string-length()),$val:=$bin ! format-integer(.,string-join((1 to $len) ! 0)) return string-join((1 to $len) ! (if (substring($val[1],.,1) eq substring($val[2],.,1)) then 0 else 1))'
1101000
$ xidel -se 'let $bin:=(33,73) ! x:integer-to-base(.,2),$len:=max($bin ! string-length()),$val:=$bin ! format-integer(.,string-join((1 to $len) ! 0)) return string-join((1 to $len) ! (if (substring($val[1],.,1) eq substring($val[2],.,1)) then 0 else 1)) ! x:integer(.,2)'
104
$ xidel -se 'declare function local:bin-xor($a,$b){let $bin:=($a,$b) ! x:integer-to-base(.,2),$len:=max($bin ! string-length()),$val:=$bin ! format-integer(.,string-join((1 to $len) ! 0)) return string-join((1 to $len) ! (if (substring($val[1],.,1) eq substring($val[2],.,1)) then 0 else 1)) ! x:integer(.,2)}; local:bin-xor(33,73)'
104
------------------------------------------------------------------------------------------------
$ time xidel -se 'declare function local:bin-xor($a,$b){let $bin:=($a,$b) ! x:integer-to-base(.,2),$len:=max($bin ! string-length()),$val:=$bin ! format-integer(.,string-join((1 to $len) ! 0)) return string-join((1 to $len) ! (if (substring($val[1],.,1) eq substring($val[2],.,1)) then 0 else 1)) ! x:integer(.,2)}; ((1 to 100000) ! local:bin-xor(33,73))[1]'
104
real 0m23.453s
user 0m0.031s
sys 0m0.000s
$ time xidel -se 'declare function local:bin-xor($a,$b){let $bin:=($a,$b) ! x:integer-to-base(.,2),$len:=max($bin ! string-length()),$val:=$bin ! format-integer(.,string-join((1 to $len) ! 0)),$v1:=$val[1],$v2:=$val[2] return string-join((1 to $len) ! (if (substring($v1,.,1) eq substring($v2,.,1)) then 0 else 1)) ! x:integer(.,2)}; ((1 to 100000) ! local:bin-xor(33,73))[1]'
104
real 0m21.516s
user 0m0.015s
sys 0m0.000s
let $v1:=$val[1] return substring($v1,$x,1)
...is dus iets sneller dan...
substring($val[1],$x,1)
...maar eigenlijk de moeite niet waard.
------------------------------------------------------------------------------------------------
declare function xivid:bin-xor($a as integer,$b as integer) as integer {
let $bin:=($a,$b) ! x:integer-to-base(.,2),
$len:=max($bin ! string-length()),
$val:=$bin ! format-integer(.,string-join((1 to $len) ! 0))
return
string-join(
(1 to $len) ! (
if (substring($val[1],.,1) eq substring($val[2],.,1)) then 0 else 1
)
) ! x:integer(.,2)
};
================================================================================================
[Codepoints en tekensets]
https://nl.wikipedia.org/wiki/ASCII_%28tekenset%29
https://nl.wikipedia.org/wiki/ISO_8859-1
https://en.wikipedia.org/wiki/Control_character
ASCII 7bit (2^7=128), 0 t/m 127:
- 0 t/m 127 in 16 rijen van 8.
$ xidel -se 'for $row in 0 to 15 return join((0 to 7) ! (. * 16 + $row))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 7 return $col * 16 + $row)'
$ xidel -se 'for $row in 0 to 15 return join((0 to 127)[. mod 16 eq $row])'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 127 where $col mod 16 eq $row return $col)'
0 16 32 48 64 80 96 112
1 17 33 49 65 81 97 113
2 18 34 50 66 82 98 114
3 19 35 51 67 83 99 115
4 20 36 52 68 84 100 116
5 21 37 53 69 85 101 117
6 22 38 54 70 86 102 118
7 23 39 55 71 87 103 119
8 24 40 56 72 88 104 120
9 25 41 57 73 89 105 121
10 26 42 58 74 90 106 122
11 27 43 59 75 91 107 123
12 28 44 60 76 92 108 124
13 29 45 61 77 93 109 125
14 30 46 62 78 94 110 126
15 31 47 63 79 95 111 127
- Uitlijnen. I.p.v. if ((. eq 0) or (. eq 1) or ...) then... geeft een vergelijking met een reeks ook een boolean.
$ xidel -se 'for $row in 0 to 15 return join((0 to 7) ! (. * 16 + $row) ! (if (. = (0 to 9,96 to 99)) then " "||. else .))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 7 return ($col * 16 + $row) ! (if (. = (0 to 9,96 to 99)) then " "||. else .))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 7 let $val:=$col * 16 + $row return if ($val = (0 to 9,96 to 99)) then " "||$val else $val)'
$ xidel -se 'for $row in 0 to 15 return join((0 to 127)[. mod 16 eq $row] ! (if (. = (0 to 9,96 to 99)) then " "||. else .))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 127 where $col mod 16 eq $row return if ($col = (0 to 9,96 to 99)) then " "||$col else $col)'
0 16 32 48 64 80 96 112
1 17 33 49 65 81 97 113
2 18 34 50 66 82 98 114
3 19 35 51 67 83 99 115
4 20 36 52 68 84 100 116
5 21 37 53 69 85 101 117
6 22 38 54 70 86 102 118
7 23 39 55 71 87 103 119
8 24 40 56 72 88 104 120
9 25 41 57 73 89 105 121
10 26 42 58 74 90 106 122
11 27 43 59 75 91 107 123
12 28 44 60 76 92 108 124
13 29 45 61 77 93 109 125
14 30 46 62 78 94 110 126
15 31 47 63 79 95 111 127
- Hexadecimale getallen erbij, met | als scheiding en een extra 0 voor 0 t/m 9.
$ xidel -se 'for $row in 0 to 15 return join((0 to 7) ! (. * 16 + $row) ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 7 return ($col * 16 + $row) ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 7 let $val:=$col * 16 + $row return join((if ($val = (0 to 9,96 to 99)) then " "||$val else $val,x:integer-to-base($val,16) ! (if (string-length(.) eq 1) then "0"||. else .)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join((0 to 127)[. mod 16 eq $row] ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 127 where $col mod 16 eq $row return join((if ($col = (0 to 9,96 to 99)) then " "||$col else $col,x:integer-to-base($col,16) ! (if (string-length(.) eq 1) then "0"||. else .)),"|"))'
0|00 16|10 32|20 48|30 64|40 80|50 96|60 112|70
1|01 17|11 33|21 49|31 65|41 81|51 97|61 113|71
2|02 18|12 34|22 50|32 66|42 82|52 98|62 114|72
3|03 19|13 35|23 51|33 67|43 83|53 99|63 115|73
4|04 20|14 36|24 52|34 68|44 84|54 100|64 116|74
5|05 21|15 37|25 53|35 69|45 85|55 101|65 117|75
6|06 22|16 38|26 54|36 70|46 86|56 102|66 118|76
7|07 23|17 39|27 55|37 71|47 87|57 103|67 119|77
8|08 24|18 40|28 56|38 72|48 88|58 104|68 120|78
9|09 25|19 41|29 57|39 73|49 89|59 105|69 121|79
10|0A 26|1A 42|2A 58|3A 74|4A 90|5A 106|6A 122|7A
11|0B 27|1B 43|2B 59|3B 75|4B 91|5B 107|6B 123|7B
12|0C 28|1C 44|2C 60|3C 76|4C 92|5C 108|6C 124|7C
13|0D 29|1D 45|2D 61|3D 77|4D 93|5D 109|6D 125|7D
14|0E 30|1E 46|2E 62|3E 78|4E 94|5E 110|6E 126|7E
15|0F 31|1F 47|2F 63|3F 79|4F 95|5F 111|6F 127|7F
- Tekens erbij, maar vervang 0, 7, 8, 9, 10 en 13 met spaties, omdat dit beheertekens (control characters) betreft.
$ xidel -se 'for $row in 0 to 15 return join((0 to 7) ! (. * 16 + $row) ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .),if (. = (0,7,8,9,10,13)) then " " else x:cps(.)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 7 return ($col * 16 + $row) ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .),if (. = (0,7,8,9,10,13)) then " " else x:cps(.)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 7 let $val:=$col * 16 + $row return join((if ($val = (0 to 9,96 to 99)) then " "||$val else $val,x:integer-to-base($val,16) ! (if (string-length(.) eq 1) then "0"||. else .),if ($val = (0,7,8,9,10,13)) then " " else x:cps($val)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join((0 to 127)[. mod 16 eq $row] ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .),if (. = (0,7,8,9,10,13)) then " " else x:cps(.)),"|"))'
$ xidel -se 'for $row in 0 to 15 return join(for $col in 0 to 127 where $col mod 16 eq $row return join((if ($col = (0 to 9,96 to 99)) then " "||$col else $col,x:integer-to-base($col,16) ! (if (string-length(.) eq 1) then "0"||. else .),if ($col = (0,7,8,9,10,13)) then " " else x:cps($col)),"|"))'
0|00| 16|10|► 32|20| 48|30|0 64|40|@ 80|50|P 96|60|` 112|70|p
1|01|☺ 17|11|◄ 33|21|! 49|31|1 65|41|A 81|51|Q 97|61|a 113|71|q
2|02|☻ 18|12|↕ 34|22|" 50|32|2 66|42|B 82|52|R 98|62|b 114|72|r
3|03|♥ 19|13|‼ 35|23|# 51|33|3 67|43|C 83|53|S 99|63|c 115|73|s
4|04|♦ 20|14|¶ 36|24|$ 52|34|4 68|44|D 84|54|T 100|64|d 116|74|t
5|05|♣ 21|15|§ 37|25|% 53|35|5 69|45|E 85|55|U 101|65|e 117|75|u
6|06|♠ 22|16|▬ 38|26|& 54|36|6 70|46|F 86|56|V 102|66|f 118|76|v
7|07| 23|17|↨ 39|27|' 55|37|7 71|47|G 87|57|W 103|67|g 119|77|w
8|08| 24|18|↑ 40|28|( 56|38|8 72|48|H 88|58|X 104|68|h 120|78|x
9|09| 25|19|↓ 41|29|) 57|39|9 73|49|I 89|59|Y 105|69|i 121|79|y
10|0A| 26|1A|→ 42|2A|* 58|3A|: 74|4A|J 90|5A|Z 106|6A|j 122|7A|z
11|0B|♂ 27|1B|← 43|2B|+ 59|3B|; 75|4B|K 91|5B|[ 107|6B|k 123|7B|{
12|0C|♀ 28|1C|∟ 44|2C|, 60|3C|< 76|4C|L 92|5C|\ 108|6C|l 124|7C||
13|0D| 29|1D|↔ 45|2D|- 61|3D|= 77|4D|M 93|5D|] 109|6D|m 125|7D|}
14|0E|♫ 30|1E|▲ 46|2E|. 62|3E|> 78|4E|N 94|5E|^ 110|6E|n 126|7E|~
15|0F|☼ 31|1F|▼ 47|2F|/ 63|3F|? 79|4F|O 95|5F|_ 111|6F|o 127|7F|⌂
ALT+<cp> voor weergave (Windows). # ALT 1 of ALT 127.
&#<cp>; / &#x<hex> voor HTML. #  /  of  / .
\x<hex> voor Javascript. # \x01 of \x7F.
\u00<hex> voor JSON. # \u0001 of \u007F.
- De beheertekens (control characters).
0|NUL \0 � null
7|BEL \a  bell
8|BS \b  backspace
9|HT \t 	 horizontal tab
10|LF \n line feed
13|CR \r carriage return
------------------------------------------------------------------------------------------------
Extended ASCII 8bit (2^8=256), 127 t/m 255:
- ISO 8859-1 / Latin-1 / "Unicode" in charmap.exe (Character Map).
$ xidel -se 'for $row in 0 to 15 return join((128 to 255)[. mod 16 eq $row] ! join((.,x:integer-to-base(.,16),x:cps(.)),"|"))' [--output-encoding=oem]
$ xidel -se 'for $row in 0 to 15 return join((128 to 255)[. mod 16 eq $row] ! join((.,x:integer-to-base(.,16),binary-to-string(hexBinary(x:integer-to-base(.,16)),"latin1")),"|"))'
128|80 ? 144|90 ? 160|A0 176|B0 ° 192|C0 A 208|D0 D 224|E0 à 240|F0 d
129|81 ? 145|91 ? 161|A1 ¡ 177|B1 ± 193|C1 A 209|D1 Ñ 225|E1 á 241|F1 ñ
130|82 ? 146|92 ? 162|A2 ¢ 178|B2 ² 194|C2 A 210|D2 O 226|E2 â 242|F2 ò
131|83 ? 147|93 ? 163|A3 £ 179|B3 3 195|C3 A 211|D3 O 227|E3 a 243|F3 ó
132|84 ? 148|94 ? 164|A4 ☼ 180|B4 ' 196|C4 Ä 212|D4 O 228|E4 ä 244|F4 ô
133|85 ? 149|95 ? 165|A5 ¥ 181|B5 µ 197|C5 Å 213|D5 O 229|E5 å 245|F5 o
134|86 ? 150|96 ? 166|A6 ▌ 182|B6 ¶ 198|C6 Æ 214|D6 Ö 230|E6 æ 246|F6 ö
135|87 ? 151|97 ? 167|A7 § 183|B7 · 199|C7 Ç 215|D7 x 231|E7 ç 247|F7 ÷
136|88 ? 152|98 ? 168|A8 " 184|B8 , 200|C8 E 216|D8 O 232|E8 è 248|F8 o
137|89 ? 153|99 ? 169|A9 c 185|B9 1 201|C9 É 217|D9 U 233|E9 é 249|F9 ù
138|8A ? 154|9A ? 170|AA ª 186|BA º 202|CA E 218|DA U 234|EA ê 250|FA ú
139|8B ? 155|9B ? 171|AB « 187|BB » 203|CB E 219|DB U 235|EB ë 251|FB û
140|8C ? 156|9C ? 172|AC ¬ 188|BC ¼ 204|CC I 220|DC Ü 236|EC ì 252|FC ü
141|8D ? 157|9D ? 173|AD - 189|BD ½ 205|CD I 221|DD Y 237|ED í 253|FD y
142|8E ? 158|9E ? 174|AE r 190|BE _ 206|CE I 222|DE _ 238|EE î 254|FE _
143|8F ? 159|9F ? 175|AF _ 191|BF ¿ 207|CF I 223|DF ß 239|EF ï 255|FF ÿ
128 t/m 159 zijn beheertekens. ANSI / Windows-1252 / "Windows: Western" in charmap.exe heeft deze vervangen met de volgende grafische tekens:
128|80 € 144|90
129|81 145|91 ‘
130|82 ‚ 146|92 ’
131|83 ƒ 147|93 “
132|84 „ 148|94 ”
133|85 … 149|95 •
134|86 † 150|96 –
135|87 ‡ 151|97 —
136|88 ˆ 152|98 ˜
137|89 ‰ 153|99 ™
138|8A Š 154|9A š
139|8B ‹ 155|9B ›
140|8C Œ 156|9C œ
141|8D 157|9D
142|8E Ž 158|9E ž
143|8F 159|9F Ÿ
"latin1" heeft ze dus niet, maar het "Raster Fonts" in CMD (en dus Cygwin Bash) ondersteunt ze ook niet.
Geldige opties voor $encoding: utf8, utf-32le, oem, utf-8, latin1, utf-16, utf-16be, utf-32be, utf-32.
ALT+0<cp> voor weergave (Windows). # ALT 0163 of ALT 0255.
&#<cp>; / &#x<hex> voor HTML. # £ / £ of ÿ / ÿ.
\x<hex> voor Javascript. # \xA3 of \xFF.
\u00<hex> voor JSON. # \u00A3 of \u00FF.
- Code page 437 / CP437 / OEM-US / "DOS: United States" in charmap.exe.
$ xidel -se 'for $row in 0 to 15 return join((128 to 255)[. mod 16 eq $row] ! join((.,x:integer-to-base(.,16),x:cps(.)),"|"))' --output-encoding=latin1
$ xidel -se 'for $row in 0 to 15 return join((128 to 255)[. mod 16 eq $row] ! join((.,x:integer-to-base(.,16),binary-to-string(hexBinary(x:integer-to-base(.,16)),"oem")),"|"))'
128|80 Ç 144|90 É 160|A0 á 176|B0 ░ 192|C0 └ 208|D0 ╨ 224|E0 α 240|F0 ≡
129|81 ü 145|91 æ 161|A1 í 177|B1 ▒ 193|C1 ┴ 209|D1 ╤ 225|E1 ß 241|F1 ±
130|82 é 146|92 Æ 162|A2 ó 178|B2 ▓ 194|C2 ┬ 210|D2 ╥ 226|E2 Γ 242|F2 ≥
131|83 â 147|93 ô 163|A3 ú 179|B3 │ 195|C3 ├ 211|D3 ╙ 227|E3 π 243|F3 ≤
132|84 ä 148|94 ö 164|A4 ñ 180|B4 ┤ 196|C4 ─ 212|D4 ╘ 228|E4 Σ 244|F4 ⌠
133|85 à 149|95 ò 165|A5 Ñ 181|B5 ╡ 197|C5 ┼ 213|D5 ╒ 229|E5 σ 245|F5 ⌡
134|86 å 150|96 û 166|A6 ª 182|B6 ╢ 198|C6 ╞ 214|D6 ╓ 230|E6 µ 246|F6 ÷
135|87 ç 151|97 ù 167|A7 º 183|B7 ╖ 199|C7 ╟ 215|D7 ╫ 231|E7 τ 247|F7 ≈
136|88 ê 152|98 ÿ 168|A8 ¿ 184|B8 ╕ 200|C8 ╚ 216|D8 ╪ 232|E8 Φ 248|F8 °
137|89 ë 153|99 Ö 169|A9 ⌐ 185|B9 ╣ 201|C9 ╔ 217|D9 ┘ 233|E9 Θ 249|F9 ∙
138|8A è 154|9A Ü 170|AA ¬ 186|BA ║ 202|CA ╩ 218|DA ┌ 234|EA Ω 250|FA ·
139|8B ï 155|9B ¢ 171|AB ½ 187|BB ╗ 203|CB ╦ 219|DB █ 235|EB δ 251|FB √
140|8C î 156|9C £ 172|AC ¼ 188|BC ╝ 204|CC ╠ 220|DC ▄ 236|EC ∞ 252|FC ⁿ
141|8D ì 157|9D ¥ 173|AD ¡ 189|BD ╜ 205|CD ═ 221|DD ▌ 237|ED φ 253|FD ²
142|8E Ä 158|9E ₧ 174|AE « 190|BE ╛ 206|CE ╬ 222|DE ▐ 238|EE ε 254|FE ■
143|8F Å 159|9F ƒ 175|AF » 191|BF ┐ 207|CF ╧ 223|DF ▀ 239|EF ∩ 255|FF
CMD (en dus Cygwin Bash) is standaard afgesteld op CHCP 437 (oem). Hierdoor krijg je dit rare tafereel dat --output-encoding precies andersom werkt.
ALT+<cp> voor weergave (Windows). # ALT 128 of ALT 253.
------------------------------------------------------------------------------------------------
Extended ASCII 8bit (2^8=256), 0 t/m 255:
$ xidel -se 'for $row in 0 to 31 return join((0 to 255)[. mod 32 eq $row] ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .),if (. = (0,7,8,9,10,13)) then " " else x:cps(.)),"|"))' [--output-encoding=oem]
0|00| 32|20| 64|40|@ 96|60|` 128|80|? 160|A0| 192|C0|A 224|E0|à
1|01|☺ 33|21|! 65|41|A 97|61|a 129|81|? 161|A1|¡ 193|C1|A 225|E1|á
2|02|☻ 34|22|" 66|42|B 98|62|b 130|82|? 162|A2|¢ 194|C2|A 226|E2|â
3|03|♥ 35|23|# 67|43|C 99|63|c 131|83|? 163|A3|£ 195|C3|A 227|E3|a
4|04|♦ 36|24|$ 68|44|D 100|64|d 132|84|? 164|A4|☼ 196|C4|Ä 228|E4|ä
5|05|♣ 37|25|% 69|45|E 101|65|e 133|85|? 165|A5|¥ 197|C5|Å 229|E5|å
6|06|♠ 38|26|& 70|46|F 102|66|f 134|86|? 166|A6|▌ 198|C6|Æ 230|E6|æ
7|07| 39|27|' 71|47|G 103|67|g 135|87|? 167|A7|§ 199|C7|Ç 231|E7|ç
8|08| 40|28|( 72|48|H 104|68|h 136|88|? 168|A8|" 200|C8|E 232|E8|è
9|09| 41|29|) 73|49|I 105|69|i 137|89|? 169|A9|c 201|C9|É 233|E9|é
10|0A| 42|2A|* 74|4A|J 106|6A|j 138|8A|? 170|AA|ª 202|CA|E 234|EA|ê
11|0B|♂ 43|2B|+ 75|4B|K 107|6B|k 139|8B|? 171|AB|« 203|CB|E 235|EB|ë
12|0C|♀ 44|2C|, 76|4C|L 108|6C|l 140|8C|? 172|AC|¬ 204|CC|I 236|EC|ì
13|0D| 45|2D|- 77|4D|M 109|6D|m 141|8D|? 173|AD|- 205|CD|I 237|ED|í
14|0E|♫ 46|2E|. 78|4E|N 110|6E|n 142|8E|? 174|AE|r 206|CE|I 238|EE|î
15|0F|☼ 47|2F|/ 79|4F|O 111|6F|o 143|8F|? 175|AF|_ 207|CF|I 239|EF|ï
16|10|► 48|30|0 80|50|P 112|70|p 144|90|? 176|B0|° 208|D0|D 240|F0|d
17|11|◄ 49|31|1 81|51|Q 113|71|q 145|91|? 177|B1|± 209|D1|Ñ 241|F1|ñ
18|12|↕ 50|32|2 82|52|R 114|72|r 146|92|? 178|B2|² 210|D2|O 242|F2|ò
19|13|‼ 51|33|3 83|53|S 115|73|s 147|93|? 179|B3|3 211|D3|O 243|F3|ó
20|14|¶ 52|34|4 84|54|T 116|74|t 148|94|? 180|B4|' 212|D4|O 244|F4|ô
21|15|§ 53|35|5 85|55|U 117|75|u 149|95|? 181|B5|µ 213|D5|O 245|F5|o
22|16|▬ 54|36|6 86|56|V 118|76|v 150|96|? 182|B6|¶ 214|D6|Ö 246|F6|ö
23|17|↨ 55|37|7 87|57|W 119|77|w 151|97|? 183|B7|· 215|D7|x 247|F7|÷
24|18|↑ 56|38|8 88|58|X 120|78|x 152|98|? 184|B8|, 216|D8|O 248|F8|o
25|19|↓ 57|39|9 89|59|Y 121|79|y 153|99|? 185|B9|1 217|D9|U 249|F9|ù
26|1A|→ 58|3A|: 90|5A|Z 122|7A|z 154|9A|? 186|BA|º 218|DA|U 250|FA|ú
27|1B|← 59|3B|; 91|5B|[ 123|7B|{ 155|9B|? 187|BB|» 219|DB|U 251|FB|û
28|1C|∟ 60|3C|< 92|5C|\ 124|7C|| 156|9C|? 188|BC|¼ 220|DC|Ü 252|FC|ü
29|1D|↔ 61|3D|= 93|5D|] 125|7D|} 157|9D|? 189|BD|½ 221|DD|Y 253|FD|y
30|1E|▲ 62|3E|> 94|5E|^ 126|7E|~ 158|9E|? 190|BE|_ 222|DE|_ 254|FE|_
31|1F|▼ 63|3F|? 95|5F|_ 127|7F|⌂ 159|9F|? 191|BF|¿ 223|DF|ß 255|FF|ÿ
$ xidel -se 'for $row in 0 to 31 return join((0 to 255)[. mod 32 eq $row] ! join((if (. = (0 to 9,96 to 99)) then " "||. else .,x:integer-to-base(.,16) ! (if (string-length(.) eq 1) then "0"||. else .),if (. = (0,7,8,9,10,13)) then " " else x:cps(.)),"|"))' --output-encoding=latin1
0|00 32|20 64|40 @ 96|60 ` 128|80 Ç 160|A0 á 192|C0 └ 224|E0 α
1|01 ☺ 33|21 ! 65|41 A 97|61 a 129|81 ü 161|A1 í 193|C1 ┴ 225|E1 ß
2|02 ☻ 34|22 " 66|42 B 98|62 b 130|82 é 162|A2 ó 194|C2 ┬ 226|E2 Γ
3|03 ♥ 35|23 # 67|43 C 99|63 c 131|83 â 163|A3 ú 195|C3 ├ 227|E3 π
4|04 ♦ 36|24 $ 68|44 D 100|64 d 132|84 ä 164|A4 ñ 196|C4 ─ 228|E4 Σ
5|05 ♣ 37|25 % 69|45 E 101|65 e 133|85 à 165|A5 Ñ 197|C5 ┼ 229|E5 σ
6|06 ♠ 38|26 & 70|46 F 102|66 f 134|86 å 166|A6 ª 198|C6 ╞ 230|E6 µ
7|07 39|27 ' 71|47 G 103|67 g 135|87 ç 167|A7 º 199|C7 ╟ 231|E7 τ
8|08 40|28 ( 72|48 H 104|68 h 136|88 ê 168|A8 ¿ 200|C8 ╚ 232|E8 Φ
9|09 41|29 ) 73|49 I 105|69 i 137|89 ë 169|A9 ⌐ 201|C9 ╔ 233|E9 Θ
10|0A 42|2A * 74|4A J 106|6A j 138|8A è 170|AA ¬ 202|CA ╩ 234|EA Ω
11|0B ♂ 43|2B + 75|4B K 107|6B k 139|8B ï 171|AB ½ 203|CB ╦ 235|EB δ
12|0C ♀ 44|2C , 76|4C L 108|6C l 140|8C î 172|AC ¼ 204|CC ╠ 236|EC ∞
13|0D 45|2D - 77|4D M 109|6D m 141|8D ì 173|AD ¡ 205|CD ═ 237|ED φ
14|0E ♫ 46|2E . 78|4E N 110|6E n 142|8E Ä 174|AE « 206|CE ╬ 238|EE ε
15|0F ☼ 47|2F / 79|4F O 111|6F o 143|8F Å 175|AF » 207|CF ╧ 239|EF ∩
16|10 ► 48|30 0 80|50 P 112|70 p 144|90 É 176|B0 ░ 208|D0 ╨ 240|F0 ≡
17|11 ◄ 49|31 1 81|51 Q 113|71 q 145|91 æ 177|B1 ▒ 209|D1 ╤ 241|F1 ±
18|12 ↕ 50|32 2 82|52 R 114|72 r 146|92 Æ 178|B2 ▓ 210|D2 ╥ 242|F2 ≥
19|13 ‼ 51|33 3 83|53 S 115|73 s 147|93 ô 179|B3 │ 211|D3 ╙ 243|F3 ≤
20|14 ¶ 52|34 4 84|54 T 116|74 t 148|94 ö 180|B4 ┤ 212|D4 ╘ 244|F4 ⌠
21|15 § 53|35 5 85|55 U 117|75 u 149|95 ò 181|B5 ╡ 213|D5 ╒ 245|F5 ⌡
22|16 ▬ 54|36 6 86|56 V 118|76 v 150|96 û 182|B6 ╢ 214|D6 ╓ 246|F6 ÷
23|17 ↨ 55|37 7 87|57 W 119|77 w 151|97 ù 183|B7 ╖ 215|D7 ╫ 247|F7 ≈
24|18 ↑ 56|38 8 88|58 X 120|78 x 152|98 ÿ 184|B8 ╕ 216|D8 ╪ 248|F8 °
25|19 ↓ 57|39 9 89|59 Y 121|79 y 153|99 Ö 185|B9 ╣ 217|D9 ┘ 249|F9 ∙
26|1A → 58|3A : 90|5A Z 122|7A z 154|9A Ü 186|BA ║ 218|DA ┌ 250|FA ·
27|1B ← 59|3B ; 91|5B [ 123|7B { 155|9B ¢ 187|BB ╗ 219|DB █ 251|FB √
28|1C ∟ 60|3C < 92|5C \ 124|7C | 156|9C £ 188|BC ╝ 220|DC ▄ 252|FC ⁿ
29|1D ↔ 61|3D = 93|5D ] 125|7D } 157|9D ¥ 189|BD ╜ 221|DD ▌ 253|FD ²
30|1E ▲ 62|3E > 94|5E ^ 126|7E ~ 158|9E ₧ 190|BE ╛ 222|DE ▐ 254|FE ■
31|1F ▼ 63|3F ? 95|5F _ 127|7F ⌂ 159|9F ƒ 191|BF ┐ 223|DF ▀ 255|FF
$ xidel -se '
for $row in 0 to 31 return
join(
(0 to 255)[. mod 32 eq $row] ! join(
(
if (. = (0 to 9,96 to 99)) then " "||. else .,
x:integer-to-base(.,16) ! (
if (string-length(.) eq 1) then "0"||. else .
),
if (. = (0,7,8,9,10,13)) then " " else x:cps(.)
),
"|"
)
)
'
================================================================================================
[Epoch/datum/tijd/tijdzone conversies]
$ date +%:z
+01:00 # UTC+1 (Nederland, wintertijd).
$ xidel -se 'implicit-timezone()'
$ xidel -se 'time("00:00:00") - time("00:00:00'$(date +%:z)'")' # Vóór xidel-0.9.9.7433-8b7ba70.
PT1H # Tijdzone als dayTimeDuration().
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"Unix time (also known as Epoch time, POSIX time, seconds since the Epoch, or UNIX Epoch time) is a system for describing a point in time. It is the number of seconds that have elapsed since the Unix epoch, minus leap seconds; the Unix epoch is 00:00:00 UTC on 1 January 1970" (https://en.wikipedia.org/wiki/Unix_time)
$ date -d @946683000 -u '+%FT%T%:z'
1999-12-31T23:30:00+00:00 # UTC tijd.
$ xidel -se 'duration("PT946683000S") + dateTime("1970-01-01T00:00:00Z")'
$ xidel -se '946683000 * duration("PT1S") + dateTime("1970-01-01T00:00:00Z")'
1999-12-31T23:30:00Z # UTC tijd.
$ date -d @946683000 '+%FT%T%:z'
$ xidel -se 'adjust-dateTime-to-timezone(946683000 * duration("PT1S") + implicit-timezone() + dateTime("1970-01-01T00:00:00"))'
$ xidel -se 'adjust-dateTime-to-timezone(946683000 * duration("PT1S") + dateTime("1970-01-01T00:00:00Z"))'
2000-01-01T00:30:00+01:00 # UTC+1 tijd.
$ date -d 2000-01-01T00:30:00+01:00 '+%s'
$ xidel -se '(dateTime("2000-01-01T00:30:00+01:00") - dateTime("1970-01-01T00:00:00") - implicit-timezone()) div dayTimeDuration("PT1S")'
$ xidel -se '(dateTime("2000-01-01T00:30:00+01:00") - dateTime("1970-01-01T00:00:00Z")) div dayTimeDuration("PT1S")'
946683000
Voor een deling is expliciet dayTimeDuration() nodig. Zie https://sourceforge.net/p/videlibri/mailman/videlibri-xidel/thread/7e952f3d-18d5-ede8-17df-8480b2594b7c%40benibela.de/#msg36722060.
$ date -d @946683000 '+%d-%m-%Y'
$ xidel -se 'format-date(adjust-dateTime-to-timezone(946683000 * duration("PT1S") + dateTime("1970-01-01T00:00:00Z")),"[D01]-[M01]-[Y]")'
01-01-2000
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$ xidel -se '
adjust-dateTime-to-timezone(dateTime("1999-12-31T23:30:00")),
adjust-dateTime-to-timezone(dateTime("1999-12-31T23:30:00Z")),
adjust-dateTime-to-timezone(dateTime("1999-12-31T23:30:00-05:00")),
adjust-dateTime-to-timezone(dateTime("1999-12-31T23:30:00-05:00"),duration("PT0S")),
adjust-dateTime-to-timezone(dateTime("1999-12-31T23:30:00-05:00"),duration("PT9H"))
'
1999-12-31T23:30:00+01:00 # Datetime zonder tijdzone wordt beschouwd als lokaal en krijgt alleen de lokale tijdzone er achter.
2000-01-01T00:30:00+01:00 # Datetime met tijdzone wordt geconverteerd naar lokale datetime; UTC+1 (Nederland, wintertijd).
2000-01-01T05:30:00+01:00 # Van UTC−5 (New York) naar UTC+1 (Nederland, wintertijd).
2000-01-01T04:30:00Z # Van UTC−5 (New York) naar UTC.
2000-01-01T13:30:00+09:00 # Van UTC−5 (New York) naar UTC+9 (Japan).
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$ xidel -se '
"'$(date +%FT%T%:z)'",
"'$(date -u +%FT%T%:z)'",
current-dateTime(),
adjust-dateTime-to-timezone(current-dateTime(),duration("PT0S")),
format-dateTime(current-dateTime() + duration("PT0.5S"),"[Y]-[M01]-[D01]T[H01]:[m01]:[s01][Z]"),
adjust-dateTime-to-timezone(
dateTime(
format-dateTime(current-dateTime() + duration("PT0.5S"),"[Y]-[M01]-[D01]T[H01]:[m01]:[s01][Z]")
),
duration("PT0S")
)
'
2020-12-18T13:53:33+01:00 # Huidige lokale tijd.
2020-12-18T12:53:33+00:00 # Huidige UTC tijd.
2020-12-18T13:53:33.718+01:00 # Huidige lokale tijd.
2020-12-18T12:53:33.718Z # Huidige UTC tijd.
2020-12-18T13:53:34+01:00 # Huidige lokale tijd, afgerond.
2020-12-18T12:53:34Z # Huidige UTC tijd, afgerond.
$ xidel -se '
"'$(date +%s)'",
(current-dateTime() - dateTime("1970-01-01T00:00:00Z")) div dayTimeDuration("PT1S"),
round((current-dateTime() - dateTime("1970-01-01T00:00:00Z")) div dayTimeDuration("PT1S"))
'
1608296013
1608296013.718
1608296014
------------------------------------------------------------------------------------------------
Afronden:
$ xidel -se '
format-time(time("00:19:06.040"),"[H01]:[m01]:[s01]"),
format-time(time("00:19:06.540"),"[H01]:[m01]:[s01]"),
format-time(time("00:19:06.540") + duration("PT0.5S"),"[H01]:[m01]:[s01]")
'
00:19:06
00:19:06
00:19:07
------------------------------------------------------------------------------------------------
Zomer-/Wintertijd gecorrigeerde dateTime:
$ xidel -s --module=functx-1.0.1-doc.xq -e 'functx:day-of-week("2020-12-25")' # http://www.xqueryfunctions.com/xq/functx_day-of-week.html
$ xidel -se 'days-from-duration(date("2020-12-25") - date("1901-01-06")) mod 7'
5 # 0 = zondag, 6 = zaterdag.
$ xidel -se '("zo","ma","di","wo","do","vr","za")[days-from-duration(date("2020-12-25") - date("1901-01-06")) mod 7 + 1]'
$ xidel -se '("zo","ma","di","wo","do","vr","za")[days-from-duration(date("2020-12-25") - date("0000-01-01")) mod 7 + 1]'
vr # Eerste Kerstdag 2020 was dus op een vrijdag.
functx:day-of-week() gebruikt 1901-01-06, een zondag, als referentiepunt, maar teruggerekend was 1 januari in het jaar 0 ook een zondag.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$ xidel -se 'for $month in ("03","10") return (25 to 31)[days-from-duration(date(`2020-{$month}-{.}`) - date("0000-01-01")) mod 7 eq 0]'
29 # 29 maart 2020, de laatste zondag van de maand, begin zomertijd.
25 # 25 oktober 2020, de laatste zondag van de maand, einde zomertijd.
$ xidel -se 'for $month in ("03","10") let $day:=(25 to 31)[days-from-duration(date(`{year-from-dateTime(current-dateTime())}-{$month}-{.}`) - date("0000-01-01")) mod 7 eq 0] return dateTime(`{year-from-dateTime(current-dateTime())}-{$month}-{$day}T01:00:00Z`)'
2020-03-29T01:00:00Z # Begin zomertijd.
2020-10-25T01:00:00Z # Einde zomertijd.
Vóór 1996 golden er andere regels, maar aangezien de kans vrij groot is dat de data die Xivid ontleedt allemaal
van ná die tijd is ga ik die hier niet in betrekken. Zie https://nl.wikipedia.org/wiki/Zomertijd#Nederland.
----------------------------------------------------------------
$ xidel -se 'declare function local:is-summertime($arg as dateTime) as boolean {let $dst:=for $month in ("03","10") let $day:=(25 to 31)[days-from-duration(date(`{year-from-dateTime($arg)}-{$month}-{.}`) - date("0000-01-01")) mod 7 eq 0] return dateTime(`{year-from-dateTime($arg)}-{$month}-{$day}T01:00:00Z`) return $dst[1] le dateTime($arg) and dateTime($arg) lt $dst[2]}; local:is-summertime(dateTime("2020-03-29T01:00:00Z"))'
true # 2020-03-29T01:00:00Z is kleiner of gelijk aan 2020-03-29T01:00:00Z en 2020-03-29T01:00:00Z is kleiner dan 2020-10-25T01:00:00Z.
----------------------------------------------------------------
$ xidel -se 'declare function local:adjust-dateTime-to-dst($arg as anyAtomicType) as dateTime {let $is-summertime:=function($arg as dateTime) as boolean {let $dst:=for $month in ("03","10") let $day:=(25 to 31)[days-from-duration(date(`{year-from-dateTime($arg)}-{$month}-{.}`) - date("0000-01-01")) mod 7 eq 0] return dateTime(`{year-from-dateTime($arg)}-{$month}-{$day}T01:00:00Z`) return $dst[1] le dateTime($arg) and dateTime($arg) lt $dst[2]} return adjust-dateTime-to-timezone(dateTime($arg),if ($is-summertime(current-dateTime())) then if ($is-summertime(dateTime($arg))) then implicit-timezone() else implicit-timezone() - duration("PT1H") else if ($is-summertime(dateTime($arg))) then implicit-timezone() + duration("PT1H") else implicit-timezone())}; local:adjust-dateTime-to-dst("2020-03-29T01:00:00Z")'
2020-03-29T03:00:00+02:00
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
declare function xivid:adjust-dateTime-to-dst($arg as anyAtomicType) as dateTime {
let $is-summertime:=function($arg as dateTime) as boolean {
let $dst:=
for $month in ("03","10")
let $day:=(25 to 31)[
days-from-duration(
date(`{year-from-dateTime($arg)}-{$month}-{.}`) - date("0000-01-01")
) mod 7 eq 0
] return
dateTime(`{year-from-dateTime($arg)}-{$month}-{$day}T01:00:00Z`)
return
$dst[1] le dateTime($arg) and dateTime($arg) lt $dst[2]
}
return