fixing chars

This commit is contained in:
2025-11-25 10:46:17 +01:00
parent 7abe603a01
commit b61639db85

View File

@@ -21,8 +21,10 @@ add_file() {
# Add section header and code listing (no language-specific highlighting) # Add section header and code listing (no language-specific highlighting)
echo "\\subsection{${escaped_path}}" >> "$OUTPUT_FILE" echo "\\subsection{${escaped_path}}" >> "$OUTPUT_FILE"
echo "\\begin{lstlisting}[caption={${escaped_path}}]" >> "$OUTPUT_FILE" echo "\\begin{lstlisting}[caption={${escaped_path}}]" >> "$OUTPUT_FILE"
# Sanitize UTF-8: convert to ASCII with transliteration to avoid invalid UTF-8 bytes # Convert to ASCII: transliterate what's possible, drop the rest
iconv -f UTF-8 -t ASCII//TRANSLIT "$filepath" >> "$OUTPUT_FILE" 2>/dev/null || cat "$filepath" >> "$OUTPUT_FILE" # LC_ALL=C forces ASCII locale for consistent behavior across environments
LC_ALL=C iconv -f UTF-8 -t ASCII//TRANSLIT//IGNORE "$filepath" 2>/dev/null >> "$OUTPUT_FILE" || \
LC_ALL=C tr -cd '\11\12\15\40-\176' < "$filepath" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE" echo "" >> "$OUTPUT_FILE"
echo "\\end{lstlisting}" >> "$OUTPUT_FILE" echo "\\end{lstlisting}" >> "$OUTPUT_FILE"
echo "" >> "$OUTPUT_FILE" echo "" >> "$OUTPUT_FILE"