Function: rng-file-name-uri
rng-file-name-uri is a byte-compiled function defined in
rng-uri.el.gz.
Signature
(rng-file-name-uri F)
Documentation
Return a URI for the filename F.
Multibyte characters are left as is. Use rng-uri-escape-multibyte to
escape them using %HH.
Source Code
;; Defined in /usr/src/emacs/lisp/nxml/rng-uri.el.gz
;;; rng-uri.el --- URI parsing and manipulation -*- lexical-binding:t -*-
;; Copyright (C) 2003, 2007-2026 Free Software Foundation, Inc.
;; Author: James Clark
;; Keywords: text, hypermedia, languages, XML
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(defun rng-file-name-uri (f)
"Return a URI for the filename F.
Multibyte characters are left as is. Use `rng-uri-escape-multibyte' to
escape them using %HH."
(setq f (expand-file-name f))
(let ((url
;; FIXME. Explain why the pattern doesn't also have "!$&'()*+,/:@=".
;; See Internet RFC 3986 section 2.2.
(replace-regexp-in-string "[]\0-\s\"#%;<>?[\\^`{|}\177]"
'rng-percent-encode f)))
(concat "file:"
(if (and (> (length url) 0)
(= (aref url 0) ?/))
"//"
"///")
url)))