반응형
블로그 이미지
sense.45

공지사항

최근에 올라온 글

최근에 달린 댓글

글 보관함

calendar

1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28

php json_encode 한글깨짐

2019. 2. 21. 11:26 | Posted by sense.45
반응형

php는 참 많은 기능을 제공한다.


json_encode도 한 기능이다.


이전에는 일일이 파싱해서 포멧을 마춰서 노가다를 했었는데~


json_encode는 이것을 자동으로 해준다.


참 편하다.~~~~~~~~~~


한글만 안깨지면~` 좋은데 말입니다.....


\ud55c\uae00<-- 이렇게 나옵니다.



(출처:https://stackoverflow.com/questions/18496557/pdo-utf-8-encoding-issue)
(출처:https://stackoverflow.com/questions/4475548/pdo-mysql-and-broken-utf-8-encoding)
처음에는 DB 세팅이 틀렸나~ 이리저리 보니 다 맞다.

1. $conn = new PDO('mysql:host=192.168.0.1;port=1234;dbname=' . $this->dbName , $this->user, $this->pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") );


1. $conn->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, 'SET NAMES utf8');

1. $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);

1. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);


//위의 방법들을 다해봐도 안됨다.
//DB의 문제는 아니었음.

(출처:http://php.net/manual/en/function.json-encode.php)
옵션이 있답니다.
JSON_UNESCAPED_UNICODE를 선택하면 됩니다.

한글<--  이제 잘 나옵니다.







반응형

'PHP' 카테고리의 다른 글

PHP 로그남기기 error_log  (0) 2018.12.01
Centos 7 PHP 7.2  (0) 2018.07.21

안드로이드 WIFI 연결 체크

2019. 2. 12. 11:21 | Posted by sense.45
반응형

WIFI 연결 체크




private boolean checkWifiOnAndConnected() {
    WifiManager wifiMgr = (WifiManager) getSystemService(Context.WIFI_SERVICE);

    if (wifiMgr.isWifiEnabled()) { // Wi-Fi adapter is ON

        WifiInfo wifiInfo = wifiMgr.getConnectionInfo();

        if( wifiInfo.getNetworkId() == -1 ){
            return false; // Not connected to an access point
        }
        return true; // Connected to an access point
    }
    else {
        return false; // Wi-Fi adapter is OFF
    }
}


<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

출처 : https://stackoverflow.com/questions/3841317/how-do-i-see-if-wi-fi-is-connected-on-android





public static String getNetworkType(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo info = cm.getActiveNetworkInfo();
    return info.getTypeName();
}


아래 함수는 약간만 손보면 사용하기 좋겠슴다.

public static boolean isInternetIsConnected(Context context) {
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
    if (activeNetwork != null) { // connected to the internet
        if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
            // connected to wifi
            return true;

        } else if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
            // connected to the mobile provider's data plan
            return true;
        }
    } else {
        // not connected to the internet
        return false;
    }
    return false;
}


출처 : https://stackoverflow.com/questions/48077755/how-to-check-programmatically-that-wifi-is-connected-or-data-pack-is-enabled-but


반응형

'Android' 카테고리의 다른 글

안드로이드 Calendar.getInstance API level24  (0) 2018.07.10
NFC NTAG 213  (1) 2018.03.26
How to Change the Text Color of a Substring  (0) 2018.03.20

CentOS7 nodeJs 설치

2018. 12. 17. 16:33 | Posted by sense.45
반응형

1. yum epel 

$ yum repolist

epel저장소가 없다면

# yum install epel-release



2. nodejs, npm 설치

# yum install npm nodejs


3. 버전 확인

$ node -v
$ npm -v



http://kwangsics.tistory.com/entry/CentOs7-nodeJs-%EC%84%A4%EC%B9%98


https://linuxize.com/post/how-to-install-node-js-on-centos-7/

반응형
이전 1 2 3 4 5 다음