<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://php.apsique.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>Php y otras yerbas - Detectando UTF8 en ruby - Comentarios</title>
 <link>http://php.apsique.com/contenido/detectando_utf8_ruby</link>
 <description>Comentarios para &quot;Detectando UTF8 en ruby&quot;</description>
 <language>es</language>
<item>
 <title>Gracias</title>
 <link>http://php.apsique.com/contenido/detectando_utf8_ruby#comment-15112</link>
 <description>&lt;p&gt;Gracias, Stan. Lo mismo deseo para ti.&lt;br /&gt;
Como aún falta año nuevo, para esas fechas te doy el abrazo virtual :)&lt;br /&gt;
Claudio Bustos&lt;br /&gt;
Webmaster de Apsique y de este sitio.&lt;/p&gt;
</description>
 <pubDate>Mon, 26 Dec 2005 17:37:26 -0800</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">comment 15112 at http://php.apsique.com</guid>
</item>
<item>
 <title>offtopic</title>
 <link>http://php.apsique.com/contenido/detectando_utf8_ruby#comment-15098</link>
 <description>&lt;p&gt;Feliz Navidad man :D que lo disfrutes en compañia de tus seres amados :)&lt;/p&gt;
</description>
 <pubDate>Sun, 25 Dec 2005 03:03:58 -0800</pubDate>
 <dc:creator>Stan</dc:creator>
 <guid isPermaLink="false">comment 15098 at http://php.apsique.com</guid>
</item>
<item>
 <title>Detectando UTF8 en ruby</title>
 <link>http://php.apsique.com/contenido/detectando_utf8_ruby</link>
 <description>&lt;p&gt;Trabajando en catori, me di cuenta que era muy conveniente transformar todos los datos de los archivos, tales como el nombre del artista y ese tipo de cosas, en UTF-8. El problema, claro está, es saber si el string ya está en el código citado.
La siguiente adición a la clase &lt;code&gt;String&lt;/code&gt; permite, de forma muy bruta, determinar si estamos ante ascii, utf8 o iso-8859-1. Para convertir a utf8, se requiere tener la extensión &#039;iconv&#039; de ruby.&lt;/p&gt;
&lt;p&gt;Cuando tenga un poco de tiempo, voy a portar a C esta adición, ya que la utilizo mucho y en el lenguaje de la letrita podría ganar algunos valiosos segundos&lt;/p&gt;
&lt;div class=&#039;code&#039;&gt;&lt;div class=&quot;hl-main&quot;&gt;&lt;ol class=&quot;hl-main&quot;&gt;&lt;li&gt;&amp;nbsp;&lt;span class=&quot;hl-reserved&quot;&gt;require&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;iconv&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;cuenta&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;ascii&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;true&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;each_byte&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;{|&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;|&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;cuenta&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; != &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;b10&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;iso8859&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;cuenta&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;-=&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;elsif&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &amp;amp; &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0x80&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;ascii&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; == &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;b110&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;cuenta&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;elsif&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; == &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;b1110&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;cuenta&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;elsif&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;byte&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &amp;gt;&amp;gt; &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; == &lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;b11110&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;cuenta&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;hl-number&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;                &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;iso8859&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;            &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    }&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;return&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;ascii&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;ascii&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;utf8&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;def&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;to_utf8&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;        &lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;encoding&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;iso8859&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&#039;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; ? &lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;Iconv&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-string&quot;&gt;iso-8859-1&lt;/span&gt;&lt;span class=&quot;hl-quotes&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;iconv&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;hl-identifier&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;hl-brackets&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt; : &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;    &lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;end&lt;/span&gt;&lt;span class=&quot;hl-code&quot;&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;hl-reserved&quot;&gt;end&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;</description>
 <comments>http://php.apsique.com/contenido/detectando_utf8_ruby#comments</comments>
 <category domain="http://php.apsique.com/categoria/temas_generales/programacion">Programación</category>
 <category domain="http://php.apsique.com/lenguajes/ruby">Ruby</category>
 <category domain="http://php.apsique.com/categoria/busquedas_comunes/detectando_utf8">detectando utf8</category>
 <category domain="http://php.apsique.com/categoria/busquedas_comunes/utf8">utf8</category>
 <pubDate>Fri, 23 Dec 2005 23:59:07 -0800</pubDate>
 <dc:creator>clbustos</dc:creator>
 <guid isPermaLink="false">535 at http://php.apsique.com</guid>
</item>
</channel>
</rss>
