Converting HTML entities to UTF-8 in VimScript

I wrote a small script to fetch a web page title, inserting it as amarkdown formatted link: [title](URL) One of of the issues I ran into was that some titles contain HTML entities and Vim has no built-in way to deal with this.

The solution I came up with wasn’t that grand, but the interesting part was that I learned about a UNIX utility, that also ships with MacOS, called textutil.

The solution was to do a system call passing a string with HTML entities, getting back a UTF-8 formatted string that VIM understands. Here is example that you can inVim:

let oldtitle ='&#128075; hello &lt; world &#x1f310; <   &#60 It&#8217;s a great day.'
let newtitle = system( 'echo ' . shellescape(oldtitle) . ' | textutil -convert txt -format html -stdin -stdout')
echo newtitle

Example output.

The special part I want to point your attention to is ' | textutil -convert txt -format html -stdin -stdout'. This pipes the title into the textutil command which does all the conversions for us.

You can find the full function below.

function! AddLink()
	let url = input('URL to add? ')
	if empty(url)
	let html = system('curl -s ' . shellescape(url))
	let regex = '\c.*head.*<title[^>]*>\_s*\zs.\{-}\ze\_s*<\/title>'
	let title = substitute(matchstr(html, regex), "\n", ' ', 'g')
	let title = system( 'echo ' . shellescape(title) . ' | textutil -convert txt -format html -stdin -stdout')
	if empty(title)
		let title = 'Unknown'
	put ='[' . title . '](' . url . ')'

Comparing Software Engineering to RailRoads in the 1800’s

An amazing (biased) talk about the rust language by one of the core contributors. Comparing accidents in the rail road industry to computer programming and memory safety.

Getting air-breaks approved in passenger and freight trains took a long time.

I’m starting to consider Rust as my next language to learn. The idea is growing in me as Rust allows you to write software at a much lower systems level. The other languages I know (PHP, Javascript, GO) are more targeted at web and server technologies. I have yet to write code for an embedded system.

Have a listen to the talk. I found it very interesting and I’m sure you will too.

When are you proficient in a programming language?

Learning a programming language gives you the opportunity to explore other problem domains alongside new approaches to addressing familiar problems.

I write this as I was looking for the answer to exactly this question. There were many opinions that had me confused, some from ancient rockstar ninjas who command CPUS at will and others from earnest people who are also seeking.

Why would one ask such a question in the first place? It seems like the actual issue is 2 fold. For me it is firstly; when can this go on my resume. Secondly and probably more specific to me: when to move on to the next language or skill. When can I check off my to-do list and say that I know a programming language?

After looking at many other ideas, In my opinion: You are proficient in a language when you are able to read, understand and debug code along with deploying to production.

If you can read, write and execute you are well on your way and I would consider this profecient. Beyond this, optionally, persue mastery. Though in order to keep a language on your resume, make sure to continually read, understand and debug.

Link to other opinions: