[spirit] get_script method

Keshav Krity <[email protected]> Sat, 5 May 2012 12:09:09 +0530
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <F0552EF0490DB34FBEBC42E5AB9A4F9CEA606653AE@indiambx02.corp.adobe.com>
--===============6757512534016101157==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_F0552EF0490DB34FBEBC42E5AB9A4F9CEA606653AEindiambx02cor_"

--_000_F0552EF0490DB34FBEBC42E5AB9A4F9CEA606653AEindiambx02cor_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

I am trying to get the script name for a given Unicode value. This is the m=
ethod I am calling.

http://www.boost.org/doc/libs/1_49_0/boost/spirit/home/support/char_encodin=
g/unicode/query.hpp

inline properties::script get_script(::boost::uint32_t ch)
{
     return static_cast<properties::script>(detail::script_lookup(ch) & 0x3=
F);
}


enum script

{

.

.

.

common =3D 92,

unknown =3D 93

}



This api is not returning "common" script for characters such as space. The=
 reason being the & operation with 0x3F. It restricts the return value to t=
he range 0-63. Thus the values in the enum "script" greater that 63 will ne=
ver be returned.

I fail to understand the logic behind this. Can somebody please explain the=
 behavior, why the values are being restricted to top 64 only?

Thanks


--_000_F0552EF0490DB34FBEBC42E5AB9A4F9CEA606653AEindiambx02cor_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:"Courier New";}
.MsoChpDefault
	{mso-style-type:export-only;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext=3D"edit">
  <o:idmap v:ext=3D"edit" data=3D"1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>I
am trying to get the script name for a given Unicode value. This is the met=
hod
I am calling. <o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'><o:p>&nbsp;</o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'><a
href=3D"http://www.boost.org/doc/libs/1_49_0/boost/spirit/home/support/char=
_encoding/unicode/query.hpp">http://www.boost.org/doc/libs/1_49_0/boost/spi=
rit/home/support/char_encoding/unicode/query.hpp</a><o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'><o:p>&nbsp;</o:p></span></p>

<p class=3DMsoNormal><i><span style=3D'font-size:10.0pt;font-family:"Courie=
r New"'>inline
properties::script get_script(::boost::uint32_t ch)<o:p></o:p></span></i></=
p>

<p class=3DMsoNormal><i><span style=3D'font-size:10.0pt;font-family:"Courie=
r New"'>{<o:p></o:p></span></i></p>

<p class=3DMsoNormal><i><span style=3D'font-size:10.0pt;font-family:"Courie=
r New"'>&nbsp;&nbsp;&nbsp;&nbsp;
return static_cast&lt;properties::script&gt;(detail::script_lookup(ch) &amp=
; <span
style=3D'color:red'>0x3F</span>);<o:p></o:p></span></i></p>

<p class=3DMsoNormal><i><span style=3D'font-size:10.0pt;font-family:"Courie=
r New"'>}<o:p></o:p></span></i></p>

<p class=3DMsoNormal><i><span style=3D'font-size:10.0pt;font-family:"Courie=
r New"'><o:p>&nbsp;</o:p></span></i></p>

<pre><i>enum script<o:p></o:p></i></pre><pre><i>{<o:p></o:p></i></pre><pre>=
<i>.<o:p></o:p></i></pre><pre><i>.<o:p></o:p></i></pre><pre><i>.<o:p></o:p>=
</i></pre><pre><i>common =3D 92,<o:p></o:p></i></pre><pre><i>unknown =3D 93=
<o:p></o:p></i></pre><pre><i>}<o:p></o:p></i></pre><pre><o:p>&nbsp;</o:p></=
pre><pre>This api is not returning &#8220;common&#8221; script for characte=
rs such as space. The reason being the &amp; operation with 0x3F. It restri=
cts the return value to the range 0-63. Thus the values in the enum &#8220;=
script&#8221; greater that 63 will never be returned. <o:p></o:p></pre>

<p class=3DMsoNormal><o:p>&nbsp;</o:p></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>I
fail to understand the logic behind this. Can somebody please explain the
behavior, why the values are being restricted to top 64 only?<o:p></o:p></s=
pan></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'><o:p>&nbsp;</o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'>Thanks<o:p></o:p></span></p>

<p class=3DMsoNormal><span style=3D'font-size:10.0pt;font-family:"Courier N=
ew"'><o:p>&nbsp;</o:p></span></p>

</div>

</body>

</html>

--_000_F0552EF0490DB34FBEBC42E5AB9A4F9CEA606653AEindiambx02cor_--


--===============6757512534016101157==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
--===============6757512534016101157==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Spirit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-devel

--===============6757512534016101157==--