Solve the problem of garbled Android LogCat output (GO)

Source: Internet
Author: User
Tags dateformat

Android The log system provides the ability to record and view system debug information. Logs are recorded from a variety of software and some system buffers.

can use adb of the Logcat command to view the contents of the system log buffer, but in the actual operation, you will find the CMD of the DOS interface above, use Logcat Command Direct output of the Chinese content is garbled. such as:


and this problem only appears in the use Logcat print the log directly in the current DOS window will appear while using the Logcat saving the log as a file, and then opening it with the text Editing tool, appears normal.


It's obviously because DOS the encoding of the window display is the same Logcat the different garbled problems caused by the log. the default encoding for DOS windows is GBK, while LogCat prints UTF-8 encoding, so to set the DOS character encoding:


1 . Enter chcp 65001 under the current command line and press ENTER. At this point, the current code page is using UTF-8 encoding.



2, modify the window properties, change the font right-click on the command line title bar, select "Properties", "Font", change the font to True type "Lucida Console", and then click OK to apply the property to the current window.

3, this time again using LOGCAT, the console display Chinese,

Supplementary partial character encoding corresponding code:

65001 -- UTF-8

936 --Simplified Chinese

950 --Traditional Chinese

437 --United States / Canadian English

932 --Japanese

949 --Korean

866 --Russian

Note:

Use of Logcat
[ADB] logcat [<option>] ... [<filter-spec>] ...
Filter statements are described in the following format tag:priority ..., tag is a label, priority is the lowest level of reporting for the label. The priority of the log can be obtained from the above tag. You can write tag:priority multiple times in the filter
ADB logcat tag1:i Tag2:d *:s
The last element of the expression above *:s, is to set all the labels as "silent", all the logs are only shown with "View" and "MyApp", another use of *:s is to be able to ensure that the log output is in accordance with the filter description limit, Also let the filter output to the log as an item.

For example:

[Java]View Plaincopy
    1. Private   static final String TAG = "TEST";

[Java]View Plaincopy
  1. Date date = New  Date (System.currenttimemillis ());
  2. DateFormat formatter_full = dateformat.getdateinstance (dateformat.full);
  3. LOG.I (TAG, Formatter_full.format (date));
  4. DateFormat Formatter_long = dateformat.getdateinstance (Dateformat.long);
  5. LOG.I (TAG, Formatter_long.format (date));
  6. DateFormat Formatter_medium = dateformat.getdateinstance (Dateformat.medium);
  7. LOG.I (TAG, Formatter_medium.format (date));
  8. DateFormat Formatter_short = dateformat.getdateinstance (Dateformat.short);
  9. LOG.I (TAG, Formatter_short.format (date));



Then type in cmd: adb logcat test:i *:s
Get


Above partial reprint from: http://blog.sina.com.cn/s/blog_93731f0c0100vz0x.html
The Eclipse installation plugin solves the garbled display in eclipse:
Subsequent:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.