MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
April
Sun Mon Tue Wed Thu Fri Sat
     
14
   
2009
Months
Apr


Tue, Apr 14, 2009 9:39 pm

Inserting a Newline Character Using Vi

To insert a newline character, i.e. to create a new line in a file using Vi on a Unix system, you can use ^M (you have to actually type Ctrl-V (i.e. the Ctrl and V keys hit simultaneously) followed by Enter to get the ^M to appear. For example, suppose that instead of commas separating elements in a list you wish to put each element on a new line.

Original lines

Gold, Silver, Bronze

Desired lines

Gold Silver Bronze

You can use the following command in Vi to replace all commas with the newline character starting from the first line in the file to the last (represented by $):

1,$ s/,/^M/g

As noted above, you need to hit Ctrl-V Enter to put the ^M in the command.

References:

  1. How to represent a new line character in a regex in VI?
    By: mbrooks
    Date: December 30, 2006
    Tek-Tips

[/software/editors/vi] permanent link

Tue, Apr 14, 2009 7:57 am

Character Encoding of Webpages

I've been validating the HTML code on the webpages I create for a few weeks using the W3C Markup Validation Service. For all of my webpages, I've been getting the warning below when I validate them:

No Character encoding declared at document level

No character encoding information was found within the document, either in an HTML meta element or an XML declaration. It is often recommended to declare the character encoding in the document itself, especially if there is a chance that the document will be read from or saved to disk, CD, etc.

The W3C site provides information on character sets and encoding of webpages at Tutorial: Character sets & encodings in XHTML, HTML and CSS.

There are, of course, many other useful references on the matter on the web. The Wikipedia article, Character encodings in HTML explains how browsers determine the character encoding of a webpage. Wikipedia provides information on issues related to the internationalization and localization, often abbreviated as i18n (where 18 stands for the number of letters between the i and the n in internationalization, a usage coined at DEC in the 1970s or 80s) and L10n respectively. The capital L in L10n helps to distinguish it from the lowercase i in i18n.

UTF-8: The Securet of Character Encoding has a good explanation of why it is advisable to specify the character encoding for your HTML documents and why using UTF-8 is recommended.

The webserver is providing information on the encoding of the webpages, i.e. it is sending Content-Type: text/html; charset=UTF-8 in the HTTP headers it sends to browsers, but I haven't been including a meta tag in the pages specifying the encoding, i.e. I haven't been using <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">. I decided to add that immediately after the <head> tag in the template I use for my webpages.

[/network/web/html] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo