Automate whitespace removal
The downloaded Unicode files contain trailing whitespace. This will now be removed immediately after downloading the files.
This commit is contained in:
parent
79cd7d034e
commit
7465f72544
4 changed files with 39 additions and 2 deletions
|
|
@ -12,3 +12,6 @@ bitsadmin /transfer wxDownloadJob /download /priority normal https://www.unicode
|
|||
|
||||
rem Download ISO 3166 (list of territories)
|
||||
bitsadmin /transfer wxDownloadJob /download /priority normal https://github.com/unicode-org/cldr/raw/main/tools/cldr-code/src/main/resources/org/unicode/cldr/util/data/territory_codes.txt %workdir%\unicode\territory_codes.txt
|
||||
|
||||
luashell removewhitespace.lua unicode/iso15924.txt
|
||||
luashell removewhitespace.lua unicode/territory_codes.txt
|
||||
|
|
|
|||
35
misc/languages/data/removewhitespace.lua
Normal file
35
misc/languages/data/removewhitespace.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
-- Assign script arguments and check validity
|
||||
fileName = arg[1]
|
||||
assert(fileName ~= nil, "Filename parameter missing!")
|
||||
|
||||
fileNameTemp = fileName .. ".tmp"
|
||||
|
||||
function trim(s)
|
||||
return s:match'^%s*(.*%S)' or ''
|
||||
end
|
||||
|
||||
-- Remove whitespace from file
|
||||
lastline = nil
|
||||
prevlen = 0
|
||||
fo2 = io.open(fileNameTemp,'wb')
|
||||
for line in io.lines(fileName) do
|
||||
newline = trim(line)
|
||||
if lastline ~= nil then
|
||||
lastlen = string.len(lastline)
|
||||
if lastlen ~= 0 then
|
||||
fo2:write(lastline .. "\n")
|
||||
elseif prevlen ~=0 and lastlen == 0 then
|
||||
fo2:write("\n")
|
||||
end
|
||||
prevlen = lastlen
|
||||
end
|
||||
lastline = newline
|
||||
end
|
||||
if string.len(lastline) > 0 then
|
||||
fo2:write(lastline .. "\n")
|
||||
end
|
||||
fo2:close()
|
||||
|
||||
-- Remove original and replace it by the file with whitespace removed
|
||||
os.remove(fileName)
|
||||
os.rename(fileNameTemp, fileName)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# ISO 15924 - Codes for the representation of names of scripts
|
||||
# Codes pour la représentation des noms d’écritures
|
||||
# Format:
|
||||
# Format:
|
||||
# Code;N°;English Name;Nom français;PVA;Unicode Version;Date
|
||||
#
|
||||
|
||||
|
|
|
|||
|
|
@ -328,4 +328,3 @@ IC - - - - # Canary Islands
|
|||
UN - UNO - - # United Nations
|
||||
|
||||
#end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue