24 lines
No EOL
2.1 KiB
HTML
24 lines
No EOL
2.1 KiB
HTML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html>
|
|
<head>
|
|
<title>read_binary_unicode_string (CFPropertyList::Binary)</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
|
</head>
|
|
<body class="standalone-code">
|
|
<pre><span class="ruby-comment cmt"># File rbBinaryCFPropertyList.rb, line 240</span>
|
|
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">read_binary_unicode_string</span>(<span class="ruby-identifier">fname</span>,<span class="ruby-identifier">fd</span>,<span class="ruby-identifier">length</span>)
|
|
<span class="ruby-comment cmt"># The problem is: we get the length of the string IN CHARACTERS;</span>
|
|
<span class="ruby-comment cmt"># since a char in UTF-16 can be 16 or 32 bit long, we don't really know</span>
|
|
<span class="ruby-comment cmt"># how long the string is in bytes</span>
|
|
<span class="ruby-identifier">buff</span> = <span class="ruby-identifier">fd</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">2</span><span class="ruby-operator">*</span><span class="ruby-identifier">length</span>)
|
|
|
|
<span class="ruby-ivar">@unique_table</span>[<span class="ruby-identifier">buff</span>] = <span class="ruby-keyword kw">true</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@unique_table</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">buff</span>)
|
|
<span class="ruby-keyword kw">return</span> <span class="ruby-constant">CFString</span>.<span class="ruby-identifier">new</span>(<span class="ruby-constant">Binary</span>.<span class="ruby-identifier">charset_convert</span>(<span class="ruby-identifier">buff</span>,<span class="ruby-value str">"UTF-16BE"</span>,<span class="ruby-value str">"UTF-8"</span>))
|
|
<span class="ruby-keyword kw">end</span></pre>
|
|
</body>
|
|
</html> |