#!/bin/sh
#] 
#] *********************
#] $ bash "$d_strings"'strings header.sh' 
# www.BillHowell.ca  15May2025 initial [chrCde, chrs] from QNial 'strings header.ndf'
# view in text editor, using constant-width font (eg courier), tabWidth = 3


#24************************24




#24************************24
# List of operators, generated with :
# $ grep  "^#]"  "$d_strings"'strings header.sh' |  sed "s/^#\]/  /"  >"$d_strings"'strings header.sh'' TblOfCont.txt' 

#




#08********08
# Setup 

# done by [Fileops, strings].sh
# source  "$d_bin"'standard header.sh'



#08********08
# code 


#] 08********08
#] [chr, str] basics 
#	see "$d_bin""Standard header.sh"
# 	date_ymdhm=$(date +"%y%m%d %kh%Mm")
# 	becho - echo to [screen, logfile]
# 	beval - echo command to [screen, logfile] then eval it
#		for extreme examples of beval : 
#		$ find  "/home/bill/PROJECTS/bin/"  -maxdepth 1  -type f  -name "*.sh"  |   tr  \\n  \\0  |  xargs -0  -IFILE  grep  --with-filename  --line-number  "beval" "FILE"  
#				backup computer [to,from] TravelUSB.sh:29
#				encrypt-open.sh:34

calc(){ awk "BEGIN { print "$*" }"; }

chr_apo="'"
chr_quote='"'
chr_tab="	"

chrs_symbols="[a-zA-Z0-9_]"
chrs_fname="[A-Za-z0-9._-]"

# sed use as, eg \([$chrL_path]+\)
# [] - will be a problem!! sometimes used in my fNams  24Sep2023 I added it in, untested
chrL_fNam="A-Za-z0-9._-()<>[]&%#"
chrL_path="$chrL_fNam"'\/'

# usually for website management, I start only with base path, worry about bookmarks later
chrL_fNamWithBookmk="A-Za-z0-9._-()<>&%#"	
chrL_pathWithBookmk="$chrL_fNamWithBookmk"'\/'


#+-----+
#] [grep, sed]*[Search, Replace]ChrsAsStrL  - for general text inputs,  eg fileReads
#]    [apo, qot] removed from lists below for pragmatism: DON'T use!!
#]    assumes that chrs have not already been escaped, 
#]       if so - this isn't needed for most (some can't escape) 
# used with :
#		'QNial check user[, WkSpace]Optrs.ndf' :  str_check[Grep, Sed][Search, Replace]Chrs
#		'file_ops.ndf' :  str[Grep, Sed][Search, Replace]_escapeProblemChrs  
#		29Oct2021 newline chr \ not included yet (affects ALL!), apo is very special  
# problematic chrs for sedSearch= ^$\&'",*.-[]{}\|/  won't do ^$&\ for now, just '",*.[]{}-/

# not a chrSedBad?: `/		# 
chrRgxpSrchBadEscL='+-.,?*&\[]-{}'		# 03Jan2026 not tested yet
chrRgxpSrchBadBadL="'"'"'					# dunno

chrGrepSrchBadEscL='^.,*$+'				# 03Jan2026 not sure if escape solves problem? 
chrGrepSrchBadBadL="'"'"&\[]-{}'

chrGrepRplcBadEscL='^$,*.'					# [apo, qot] removed for pragmatism
chrGrepRplcBadBadL="'"'"'					# 03Jan2026 not sure if escape solves problem? 

chrSedSrchBadEscL='&,.*\$^[]-+'			# can use if escaped
chrSedSrchBadBadL="'"'"{}|'				# 03Jan2026 not sure if escape solves problem? 

chrSedRplcBadEscL='&,.*\$^[]-'     
chrSedRplcBadBadL="'"'"&\/'   

# https://stackoverflow.com/questions/407523/escape-a-string-for-a-sed-replace-pattern
#    Ben Blank
# see "$d_SysMaint"'Linux/sed notes.txt'  02Aug2023 
# https://unix.stackexchange.com/questions/32907/what-characters-do-i-need-to-escape-when-using-sed-in-a-sh-script
# Here is a bash function for converting paths for use with SED: 
# 	#Escape path for use with sed 
# 	function sedPath { path=$((echo $1|sed -r 's/([\$\.\*\/\[\\^])/\\\1/g'|sed 's/[]]/\[]]/g')>&1) } 
# user2428118


#] sedChrL_legend  - chrL of special chrs that have to be encoded for sed 
#]    sed[x]To[y] - sedExpressions to [, de]-code chrSedL between [human, encoded] formats
# view in text editor, using constant-width font (eg courier), tabWidth = 3
# 
# sedChrL_legend='sedChrL_legend : the 2-letter codes for each chr are enclosed between zz
# mnemonics : 
# 		&  	a@			= ampersand
# 		'"		[s, d]q	=[single (apo), double] quote
# 		,		c@			= comma
# 		.		p@			= period
# 		*		s@			= star (asterix)
# 		/\		[f, b]s	= forward, backward] slash
# 		$		d@			= dollar sign
# 		^		u@			= up (carat)
# 		()		r[l, r]	= parenthesis [left, right]
# 		[]		s[l, r]	= square bracket [left, right]
#*		{}		c[l, r]	= curly braces (brackets) [left, right]
# 		-		m@			= minus sign
#*		|		v@			= vertical line'
#*		\t		tb			= tab  must NOT be encoded for strP!!!????
#* as per chrSedMisL, these characters are NOT encoded yet (problematic)

	chrSedL='&",.*/\$^()[]-{}|'
	chrSedUnknown='!@#%+'


# Apo        = chrSedCtrl apostrophe chr (')
# Npo        = chrSedCtrl non-apostrophe chrs
# sedXpr     = expression following sed cmd, that defines text line conversions

# chrSedCtlInn  = sedSearch problematic chrs, which must be converted to work in a sedXpr
# chrSedCtlNot  = sedSearch problematic chrs, not yet included in my [func, test]s

# the following sedXpr cannot be used directly, as 'sed "$sedXpr".  
# Copy full text following 'sed ', or use sedChrsEscSearch
# They are shown here for clarity, and echo comments for tests, log files for future reference, etc
#chrSedApoInc='"'"'								# chrSeq to include in apo-enclosed expression to include apo
														# chrSedApoInc must be [created by strSedCtrl_get_strOrigin, done manually], cannot use as variable
chrSedCtlApo="'"
chrSedCtlNpo='",*.[]{}-/'
chrSedCtlNot='^$&\'								# 16May2025 not yet included in my [func, test]s
sedXprApoFwd="s|[']|[']|"
sedXprApoRev="s|\['\]|'|"
sedXprNpoFwd='s|[/]|[/]|g;s|\"|\\"|g;s|\,|\\,|g;s|[-]|[-]|g;s|[*]|[*]|g;s|[{]|[{]|g;s|[}]|[}]|g;s#[|]#[|]#;s|\.|\\.|g;s|[]]||g;s|[[]||'
sedXprNpoRev='s|\[/\]|/|g;s|\\"|"|g;s|\\,|,|g;s|\\.|.|g;s|\[-\]|-|g;s|\[{\]|{|g;s|\[}\]|}|g;s|[*]|*|g;s#\[|\]#|#;s|[[]||g;s|[]]||g'

# 16May2025 tests 
#	11h18m 16May25$ echo  'Sam'"'"'s "best" test'  |  sed "s|[']\"[']\"[']|'|"
#	Sam's "best" test
#	>> crap, it worked, or seems to!?? why? wait for tests to confirm
#	11h23m 16May25$ echo  'Sam$chrSedApoInc "'"best" test'  |  sed "s|[']\"[']\"[']|'|"
#	> 
#	>> nyet, chrSedApoInc must be [created by strSedCtrl_get_strOrigin, done manually], cannot use as variable
#	11h28m 16May25$ echo  "$chrSedCtlNpo"  |  sed 's|\[|[|;s|\]|]|;s|\"|"|;s|\,|,|;s|\.|.|;s|\*|*|;s|[{]|{|;s|[}]|}|;s|\-|-|;s#[|]#|#'
#	",*.[]{}-/
#	>> perfect, category theory-like in one line...



# 08********08
#] characters [special, unicode] often used ... : 

#	IF  flag_debug  THEN  write '+-----+' ;  ENDIF ;  
#	IF  flag_debug  THEN  write 'characters [special, unicode] often used ...' ;  ENDIF ;  


# preferred symbols - easiest to use text eiditor to manually replace in the source document
#	raw	unpreferred 
#	`·		`•		dot product
#	`		`∫		integral sign
# I can't use this because it has strange QNial unicode properties - use backwards apostrophe instead : 
#	`		`´		forward prime for RFp
# special characters in text 
#	`.		period delimits keywords

# 03Sep2016 - this format may be critical to some of my QNial code! (changes will cause problems with legacy programs)

chrCde_tab=9
chrCde_newline=10   
chrCde_carriagereturn=13			# not normally used with Unix/Linux    
chrCde_space=32   
chrCde_quotation=34    
chrCde_apostrophe=39    
chrCde_apo="$chr_apostrophe"
chrCde_quote="$chr_quotation"
chrCde_semicolon=59    
chrCde_backApo=96						# back-slanting apostrophe    
chrCde_underscore=95    


#	str_apo= string chr_apo    

# actual chrs - most should have ' EACH string ' (eachStr) - will do later
chrs_alpha_caps='ABCDEFGHIJKLMNOPQRSTUVWXYZ'			#(eachStr) chr_codes  65- 90
chrs_alpha_small='abcdefghijklmnopqrstuvwxyz'		#(eachStr) chr_codes  97-122
chrs_alphabet="$chrs_alpha_caps$chrs_alpha_small"	#(sortup)  chr_codes [65-90,97-122]
chrs_numbers='0123456789'    								#(eachStr) chr_codes  48-57
chrs_alphaNumeric="$chrs_alphabet$chrs_numbers"		#(sortup link)    chr_codes [48-57,65-90,97-122]
chrs_operators='~!@#$%^&:+-*/[\][|]"'    			#(eachStr) chr_codes [126,33-41,etc...]
																	#    I had to "fix" several - won't work?
chrs_paren_strt='([{'    									#(eachStr) chr_codes ???
chrs_paren_stop=')]}'    									#(eachStr) chr_codes ???
chrs_parenthesis='()[]{}<>'								#(eachStr) chr_codes ???
chrs_SpcTab="$chrCde_space$chrCde_tab"							#(eachStr) chr_codes [32,9]
chrs_punctuation="$chrs_operators$chrs_SpcTab$chrs_parenth"	#(eachStr) chr_codes [126,33-41,etc...]
chrs_fnames="$chrs_alphaNumeric"'_ .,-'				# for QNial
chrs_arithmetic='*+-/='										#(eachStr) chr_codes [42,43,45,47,61]
chrs_math_spaced='+-='    									#(eachStr) chr_codes [42,43,45,47,61]
																	# for "symbols translate.ndf -> symTranslate_string"   
chrs_lineType='#$%^'																					#(eachStr)
chrs_writing="$chrs_alphaNumeric$chrs_punctuation$chrs_math_spaced$chrs_SpcTab"	#(needSort)
chrs_line="$chrCde_space$chrCde_tab$chrCde_newline"													#(needSort)
chrs_SpcTabCrNl="$chrCde_space$chrCde_tab$chrCde_newline$chrCde_carriagereturn"					#(needSort)
chrs_symbols_matlab="'``='"'"'																	#(???)

str_SpcTab=' 	'



#+-----+
#] unicode >1 byte sequences    

chrs_Greek_caps='ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΣΤΥΦΧΨΩ'   
chrs_Greek_small='αβγδεζηθικλμνξοπρςστυφχψω'      
chrs_Greek_all="$chrs_Greek_caps$chrs_Greek_small"    		# note that at least some unicode work!    
names_Greek_all='<ALPHA> <BETA> <GAMMA> <DELTA> <EPSILON> <ZETA> <ETA> <THETA> <IOTA> <KAPPA> <LAMBDA> <MU> <NU> <XI> <OMICRON> <PI> <RHO> <SIGMA> <TAU> <UPSILON> <PHI> <CHI> <PSI> <OMEGA> <alpha> <beta> <gamma> <delta> <epsilon> <zeta> <eta> <theta> <iota> <kappa> <lambda> <mu> <nu> <xi> <omicron> <pi> <rho> <sigma> <tau> <upsilon> <phi> <chi> <psi> <omega>'    
chrs_calculus='∫∮∬∂Σ'    
chrs_symbols_QNial="$chrs_alphaNumeric$chrs_Greek_all"'_´'

# a´=6  
# aε='greek letter in str'

# +-----+
#] chrs_QNialSymbols  - res ipsa loquitor (not complete, but should be safe)
# 14Aug2021 careful - use chrs_symbols_QNial with 	[strL_cutBy_chrInclL, etc]!!!    

chrs_QNialSymbols='0123456789_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'  


#+----+
#] Howell's Flat-Liner Notation (HFLN) - including unicode for QNial  

	chrs_symbols_HFLN="$chrs_alphaNumeric$chrs_Greek_all$chrs_calculus"'_´'
#	unicodes_HFLN_1=  EACH charrep  chrs_symbols_HFLN    
#	unicodes_HFLN_shapes=  EACH (gage shape) unicodes_HFLN    
#	unicodes_HFLN_2=  (2  EACHRIGHT =  unicodes_HFLN_shapes)  sublist  unicodes_HFLN    
#	unicodes_HFLN_3=  (3  EACHRIGHT =  unicodes_HFLN_shapes)  sublist  unicodes_HFLN    
#	# HFLN does not currently have 4-byte unicode symbol characters    
#	chrs_HFLN_2=  EACH char  unicodes_HFLN_2    
#	chrs_HFLN_3=  EACH char  unicodes_HFLN_3    
#	
#	# non-HFLN symbols    
#	chrs_non_HFLN='•·´∇∆≈∞≤≥∈∘'        
#	chrs_bad='·'  ''  '.'    
#	chrs_added='–“”→…’‘→…∗×−'													# 07Feb2019 add new codes here!!!    
#	chrs_all=  link  chrs_symbols_HFLN  chrs_non_HFLN  chrs_bad  chrs_added    
#	unicodes_ALL=  EACH charrep  chrs_ALL    
#	unicodes_ALL_shapes=  EACH (gage shape) unicodes_ALL    
#	unicodes_ALL_2=  (2  EACHRIGHT =  unicodes_ALL_shapes)  sublist  unicodes_ALL    
#	unicodes_ALL_3=  (3  EACHRIGHT =  unicodes_ALL_shapes)  sublist  unicodes_ALL    
#	
#	# [grep, sed, regexpr]-related - defult use of `| separator    
	chrs_sed_notSearch='$.*\/[]^|'"$chrCde_apo$chrCde_quote"    
	chrs_sed_notReplace='&\/|'"$chrCde_apo$chrCde_quote"    
#	
#	# 18Oct2021 needs work!
	chrCdes_commonSeparators="$chrCde_tab$chrCde_space$chrCde_quotation$chrCde_apo$chrCde_quote$chrCde_semicolon$chrCde_exclam$chrCde_at$chrCde_hash$chrCde_percent$chrCde_expon$chrCde_amp$chrCde_times$chrs_punctuation"    

# to see chr_codes :  
#qnial> mix EACHBOTH pair chrs_ALL  (EACH charrep chrs_ALL)  

# https://en.wikipedia.org/wiki/List_of_Unicode_characters#Latin_script
# List of Unicode characters
# Code		Glyph Decimal 	Octal 		HTML		Description 		# 
# U+00A9 	© 		0169 		0302 0251 	&copy; 	Copyright sign 	0105
# U+00B0 	° 		0176 		0302 0260 	&deg; 	Degree sign 		0112


# 24May2018 15:07 WARNING!!  >> I still have some problems with unicode
# see also "/media/bill/SWAPPER/Qnial/code development/strings - unicode usage.txt"
#	qnial> charrep '•'
#	-30 -128 -94
#	qnial> charrep '·'
#	-62 -73				bad character!
#	qnial> charrep ''
#	-18 -124 -87
#	qnial> charrep '´'
#	-62 -76
#	qnial> charrep ''
#	-18 -126 -108		bad character!
#	qnial> charrep '∫'
#	-30 -120 -85
#	qnial> charrep ''
#	-18 -123 -99		bad character!
#	qnial> charrep '∮'
#	-30 -120 -82
#	qnial> charrep '∬'
#	-30 -120 -84
#	qnial> charrep '∂'
#	-30 -120 -126
#	qnial> charrep 'Σ'
#	-50 -93
#	qnial> charrep 'Ψ'
#	-50 -88
#	qnial> charrep 'ζ'
#	-50 -74


# EACH char ( -62 EACHRIGHT pair (-1 * (tell 120)) )

# example chrSets :  
#	echo  "$chrs_QNialSymbols  	#includes sortup  (chrs_alphaNumeric '_'))
#	echo  "$chrs_symbols_QNial 	#includes '[chrs_alphaNumeric chrs_Greek_all  '_'  '´'  chrs_Greek_[caps, small])
#	echo  "$chrs_HFLN_1$unicodes_ALL$chrs_sed_notSearch$$chrs_sed_notReplace"
#	echo  "$chrs_HFLN_2$unicodes_ALL$unicodes_HFLN]_2$chrs_sed_notSearch$$chrs_sed_notReplace"
#	echo  "$chrs_HFLN_3$unicodes_ALL$unicodes_HFLN]_3$chrs_sed_notSearch$$chrs_sed_notReplace"
#	echo  "$chrs_alphaNumeric$chrCdes_commonSeparators$chrs_Greek_caps$chrs_Greek_caps_small"
#	echo  "$mix EACHBOTH pair chrs_ALL  (EACH charrep chrs_ALL)  






#08********08
# Procedures -  To run :



#08********08
# run - select one of options



# $ bash  "$d_strings"'strings header.sh'  

# enddoc
