[php]php MySQL phpMyAdmin 中文亂碼utf8 設定
在header.html
加入
mysql連線的地方
$dbc=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD)
//MAKE the connection
mysql_query("SET NAMES 'utf8'");
這樣存入table中,使用phpMyAdmin 2.10.3中看就沒有亂碼了
http://www.adsenseor.com/mysql/256.html
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
public class TCPDesktopServer implements Runnable {
public static final String SERVERIP = "220.131.10.187";
public static final int SERVERPORT = 12345;
public void run() {
try {
System.out.println("S: Connecting...");
ServerSocket serverSocket = new ServerSocket(SERVERPORT);
while (true) {
Socket client = serverSocket.accept();
System.out.println("S: Receiving...");
try {
BufferedReader in = new BufferedReader(
new InputStreamReader(client.getInputStream()));
String str = in.readLine();
System.out.println("S: Received: '" + str + "'");
} catch (Exception e) {
System.out.println("S: Error");
e.printStackTrace();
} finally {
client.close();
System.out.println("S: Done.");
}
}
} catch (Exception e) {
System.out.println("S: Error");
e.printStackTrace();
}
}
public static void main(String a[]) {
Thread desktopServerThread = new Thread(new TCPDesktopServer());
desktopServerThread.start();
}
}
package com.AtestClient;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class AtestClient extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Socket socket;
try {
InetAddress serverAddr = InetAddress.getByName("220.131.10.187");
Log.d("TCP", "C: Connecting...");
try {
socket = new Socket(serverAddr, 12345);
String message = "AndroidRes,Where is my Pig (Android)?";
Log.d("TCP", "StringAfter");
try {
Log.d("TCP", "C: Sending: '" + message + "'");
PrintWriter out = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream())),
true);
out.println(message);
} catch (Exception e) {
Log.e("TCP", "S: Error", e);
} finally {
socket.close();
}
} catch (Exception e) {
}
} catch (UnknownHostException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}// TCPServer.SERVERIP
}
}