Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ask for help, format Unicode text file 1

Status
Not open for further replies.

heiyubaiclub

Technical User
Jan 10, 2020
2
JP
For example, there is a Unicode text file that contains:
not for easy understanding, but for...

I manually insert a glyph:
not fo▲r easy under▲standing, but for...

It is required to be formatted in a program, and the output is as follows:
not ___ easy _____________, but for...

That is, the 3-letter for, becomes 3 underscores; the 13-letter understanding, becomes 13 underscores……
 
Hi

If I understand you correctly :
Code:
[teal]{[/teal]
    [b]for[/b] [teal]([/teal]i [teal]=[/teal] [purple]1[/purple][teal];[/teal] i [teal]<=[/teal] NF[teal];[/teal] i[teal]++)[/teal]
        [b]if[/b] [teal]([/teal][navy]$i[/navy] [teal]~[/teal] [fuchsia]/▲/[/fuchsia][teal]) {[/teal]
            [b]gsub[/b][teal]([/teal][fuchsia]/▲/[/fuchsia][teal],[/teal] [i][green]""[/green][/i][teal],[/teal] [navy]$i[/navy][teal])[/teal]
            [b]gsub[/b][teal]([/teal][fuchsia]/\w/[/fuchsia][teal],[/teal] [i][green]"_"[/green][/i][teal],[/teal] [navy]$i[/navy][teal])[/teal]
        [teal]}[/teal]

    [b]print[/b]
[teal]}[/teal]
Code:
[blue]master #[/blue] awk -f heiyubaiclub.awk heiyubaiclub.txt
not ___ easy _____________, but for...

Feherke.
feherke.github.io
 
%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20200111152542_yqowjb.png


Thank you very much!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top