Android Textview无法显示特殊字符?

时间:2015-02-01 09:37:05

标签: android android-webview textview

我需要显示sqlite中包含一些特殊字符的数据,例如

myStr =“Testing123ʳ”(实际值从sqlite加载)

其中包含一个小修饰符字母ʳ(U + 02B3)

请参阅此处的角色信息 http://graphemica.com/%CA%B3

我试过了

 1. myTextv.setText(Html.fromHtml(myStr))

 2. myTextv.setText("\u02B3")

 3. myTextv.setText(Html.fromHtml("ʳ"))

一切都行不通......

2 个答案:

答案 0 :(得分:2)

韩语(韩语)字符也存在同样的问题。对我来说,我的问题不是编码从服务器收到的数据,而是对我发送的请求进行编码。

我使用URLEncoder将我的String编码为百分比形式:

 String word = URLEncoder.encode(editText.getText().toString(),"UTF-8");

当我使用此编码发送请求时,响应已正确编码。

如果这不起作用,您可以尝试使用URLDecoder解码响应。我建议使用像this之类的Unicode转换器,然后查看TextView正在使用的编码。

答案 1 :(得分:0)

如果您在#define FASTLED_ESP8266_NODEMCU_PIN_ORDER #include <FastLED.h> // VARIABLES -------------------------------------------------------------|| #define MAX_NUM_LEDS 86 byte NUM_LEDS; byte FADE_SPEED; int val; bool initFinished = false; CRGBArray<MAX_NUM_LEDS> leds = {}; CRGBArray<MAX_NUM_LEDS> temp_leds = {}; int i_led = 0; int i_pixel = 0; // FUNCTIONS -------------------------------------------------------------|| // nblendU8TowardU8 and fadeTowardColor taken from Kiernan Freitag // Helper function that blends one uint8_t toward another by a given amount void nblendU8TowardU8( uint8_t& cur, const uint8_t target, uint8_t amount) { if( cur == target) return; if( cur < target ) { uint8_t delta = target - cur; delta = scale8_video( delta, amount); cur += delta; } else { uint8_t delta = cur - target; delta = scale8_video( delta, amount); cur -= delta; } } // Blend one CRGB color toward another CRGB color by a given amount. // Blending is linear, and done in the RGB color space. // This function modifies 'cur' in place. CRGB fadeTowardColor( CRGB& cur, const CRGB& target, uint8_t amount) { nblendU8TowardU8( cur.red, target.red, amount); nblendU8TowardU8( cur.green, target.green, amount); nblendU8TowardU8( cur.blue, target.blue, amount); return cur; } void initialize() { FastLED.addLeds<NEOPIXEL, 5>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); FastLED.setMaxPowerInVoltsAndMilliamps(3.3, 300); FastLED.setBrightness(25); fill_solid(leds, NUM_LEDS, CRGB::Black); FastLED.show(); initFinished = true; } // MAIN -------------------------------------------------------------|| void setup() { Serial.begin(115200); Serial.print("Arduino setup complete"); } void loop() { if(!initFinished) { NUM_LEDS = (int)Serial.read(); FADE_SPEED = (int)Serial.read(); Serial.print("The num of LEDs received: "); Serial.print(NUM_LEDS); Serial.print("The fade speed received: "); Serial.print(FADE_SPEED); initialize(); } else { // Takes in the bytearray and translate it to each LED while(Serial.available() > 0) { while(i_pixel < 3) { temp_leds[i_led][i_pixel] = Serial.read(); i_pixel++; } i_pixel = 0; i_led++; } i_pixel = 0; i_led = 0; for (int i=0; i<NUM_LEDS; i++) { fadeTowardColor(leds[i], temp_leds[i], FADE_SPEED); } FastLED.show(); } } 文件中给定了属性android:textAllCaps="true",那么即使以编程方式也不显示特殊字符也不起作用。最好将属性更改为.xml或在不需要的情况下从android:textAllCaps="false"文件中删除此属性。编码愉快。