snipt

Ctrl+h for KB shortcuts

PHP

UTF8 Para bancos mysql

1
2
3
4
5
6
7
8
<?php    		

mysql_query( "SET NAMES 'utf8'" );
mysql_query( 'SET character_set_connection=utf8' );
mysql_query( 'SET character_set_client=utf8' );
mysql_query( 'SET character_set_results=utf8' );

?>
https://snipt.net/embed/1da4a52dd9ebbce965c02bd7b983b315/
/raw/1da4a52dd9ebbce965c02bd7b983b315/
1da4a52dd9ebbce965c02bd7b983b315
php
PHP
8
2019-08-18T14:27:39
True
False
False
Jul 11, 2012 at 08:59 AM
/api/public/snipt/43764/
utf8-para-bancos-mysql
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="nb">mysql_query</span><span class="p">(</span> <span class="s2">&quot;SET NAMES &#39;utf8&#39;&quot;</span> <span class="p">);</span> </span><span id="L-4"><a name="L-4"></a><span class="nb">mysql_query</span><span class="p">(</span> <span class="s1">&#39;SET character_set_connection=utf8&#39;</span> <span class="p">);</span> </span><span id="L-5"><a name="L-5"></a><span class="nb">mysql_query</span><span class="p">(</span> <span class="s1">&#39;SET character_set_client=utf8&#39;</span> <span class="p">);</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">mysql_query</span><span class="p">(</span> <span class="s1">&#39;SET character_set_results=utf8&#39;</span> <span class="p">);</span> </span><span id="L-7"><a name="L-7"></a> </span><span id="L-8"><a name="L-8"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
charset, sql, utf8

MySQL

Find MySQL Collation and Charsets

1
2
3
4
USE database_name;

SHOW VARIABLES LIKE "character_set_database";
SHOW VARIABLES LIKE "collation_database";
https://snipt.net/embed/fdaa71b9921a6e4991919d5e578a1791/
/raw/fdaa71b9921a6e4991919d5e578a1791/
fdaa71b9921a6e4991919d5e578a1791
mysql
MySQL
4
2019-08-18T22:37:35
True
False
False
/api/public/snipt/41726/
find-mysql-collation-and-charsets
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="k">USE</span> <span class="n">database_name</span><span class="p">;</span> </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a><span class="k">SHOW</span> <span class="n">VARIABLES</span> <span class="k">LIKE</span> <span class="s2">&quot;character_set_database&quot;</span><span class="p">;</span> </span><span id="L-4"><a name="L-4"></a><span class="k">SHOW</span> <span class="n">VARIABLES</span> <span class="k">LIKE</span> <span class="s2">&quot;collation_database&quot;</span><span class="p">;</span> </span></pre></div> </td></tr></table>
charset, collation, mysql, utf8

Java

Create a US-ASCII charset.

1
2
3
4
5
// Create a CharSet that knows how to encode and decode standard
// text (US-ASCII)
import java.nio.charset.Charset;

Charset myAscii = Charset.forName("US-ASCII");
https://snipt.net/embed/70272e02114db225a0fedb443ec8da9a/
/raw/70272e02114db225a0fedb443ec8da9a/
70272e02114db225a0fedb443ec8da9a
java
Java
6
2019-08-19T03:10:59
True
False
False
/api/public/snipt/30098/
create-a-us-ascii-charset
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">// Create a CharSet that knows how to encode and decode standard</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">// text (US-ASCII)</span> </span><span id="L-3"><a name="L-3"></a><span class="kn">import</span> <span class="nn">java.nio.charset.Charset</span><span class="o">;</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="n">Charset</span> <span class="n">myAscii</span> <span class="o">=</span> <span class="n">Charset</span><span class="o">.</span><span class="na">forName</span><span class="o">(</span><span class="s">&quot;US-ASCII&quot;</span><span class="o">);</span> </span></pre></div> </td></tr></table>
charset, java

ApacheConf

..\WebServers\usr\local\apache\conf\httpd.conf

1
2
3
4
5
#
# Denwer: default charset.
#
AddDefaultCharset utf-8
AddDefaultCharset windows-1251
https://snipt.net/embed/6ec13b531007853f15ce46e8fd6eed98/
/raw/6ec13b531007853f15ce46e8fd6eed98/
6ec13b531007853f15ce46e8fd6eed98
apacheconf
ApacheConf
5
2019-07-28T22:37:40
True
False
False
/api/public/snipt/28359/
webserversusrlocalapacheconfhttpdconf
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c">#</span> </span><span id="L-2"><a name="L-2"></a><span class="c"># Denwer: default charset.</span> </span><span id="L-3"><a name="L-3"></a><span class="c">#</span> </span><span id="L-4"><a name="L-4"></a><span class="nb">AddDefaultCharset</span> utf-8 </span><span id="L-5"><a name="L-5"></a><span class="nb">AddDefaultCharset</span> windows-1251 </span></pre></div> </td></tr></table>
apache, charset, denwer