regexParser.cpp

'UTF-8 Encoding Algorithm' code example was used in W3C SPARQL JSON RegEx Parser code in 2011.

The UTF-8 Encoding Algorithm was used in W3C SPARQL JSON RegEx Parser code in 2011.

Subject: regexParser.cpp
Date: Jul, 2011
Author: ericP
Source: http://www.w3.org/2011/07/SPARQL_JSON/regexParser

A boost regex library approach to parsing JSON-format SPARQL results.

(Quick and dirtly syntax colorizing with emacs htmlize-buffer.)

/** JSONparser.cpp - boost::regex parser for the SPARQL JSON results 
format.
 * input: strings defined by 
<http://www.w3.org/TR/rdf-sparql-json-res/>.
 * requires:
 *   boost::regex - regular expression library.
 *   boost::optional - optionally initialized container, like Haskel
Maybe.
 * author: ericP, Eric Prud'hommeaux .
 * license: Apache License, Version 2.0, free like speech.
 */


/** ToUTF8 - convert ordinal references to UTF-8 sequences.
 * Out - an input_stream or something with a similar incremental 
operator=.
 */
struct ToUTF8
{
 struct InvalidUCScode : public std::runtime_error {
 ...
 };
 
 template<typename Out>
 Out operator() (const char* s, Out out) const {
     return operator()(strtol(s, (char**) NULL, 16), out);
 }
 
 template<typename Out>
 Out operator() (unsigned int ord, Out out) 
   const throw(InvalidUCScode) {
// http://www.herongyang.com/Unicode
   /UTF-8-UTF-8-Encoding-Algorithm.html
  if (ord < 0x80) {
      out = ord >> 0  & 0x7F | 0x00;
  } else if (ord < 0x0800) {
      out = ord >> 6  & 0x1F | 0xC0;
      out = ord >> 0  & 0x3F | 0x80;
  } else if (ord < 0x010000) {
      out = ord >> 12 & 0x0F | 0xE0;
      out = ord >> 6  & 0x3F | 0x80;
      out = ord >> 0  & 0x3F | 0x80;
  } else if (ord < 0x110000) {
      out = ord >> 18 & 0x07 | 0xF0;
      out = ord >> 12 & 0x3F | 0x80;
      out = ord >> 6  & 0x3F | 0x80;
      out = ord >> 0  & 0x3F | 0x80;
  } else {
      throw InvalidUCScode(ord);
  }
  return out;
 }
};
...

Table of Contents

 About This Book

 Reference Citations in 2017

 Reference Citations in 2016

 Reference Citations in 2015

 Reference Citations in 2014

 Reference Citations in 2013

 Reference Citations in 2012

Reference Citations in 2011

 Simplified Chinese Unicode table

 How to Edit a Mobile Registry With Commander

 OpenSSL in Ruby

 Utilisation de la JVisualVM en remote via jstatd

 OpenOffice.org Newsletter - April 2011

 AES Encryption / Decryption with Java 1.5 and ActionScript as3crypto

 problem in insert into database

 2X Gateway SSL

 Creating Installer

 Implement statement batch for Connector C++

 Twitter OAuth Library/HUD

 How to connect Oracle data base

regexParser.cpp

 gloria.tv downloader

 SET IDENTITY_INSERT for table fails

 Winsock TCP buffering behaviour

 Passing Array in Function

 Reference Citations in 2010

 Reference Citations in 2009

 Reference Citations in 2008

 Reference Citations in 2007

 Reference Citations in 2006

 Reference Citations in 2005

 Reference Citations in 2004

 Reference Citations in 2003

 PDF Printing Version