The task is to Write an application to run under the Android OS thattranslates text in the same encoding (for example, win-1251) and writescontent in a different encoding (for example, utf-8) and the reverse task.
When entering a message, I don't touch the encoding at all.
Then I just process a simple tap and a long tap to change the encoding.In other words, if you enter just text, everything works correctly.When you normally click, the ConvertItem method is called.
If you click for a long time, the ConvertItem2 method is called
I do this
const convertItem = (text,key) =>{var iconv = require('iconv-lite');const buf = Buffer.from(text, "binary");const str = iconv.decode(buf, "win1251");setValue(old=>old.map((value)=>{ if(value.key==key){ value.text = str } return value}))}const convertItem2 = (text,key) =>{var iconv = require('iconv-lite');const buf = Buffer.from(text, "binary");const str = iconv.decode(buf, "utf8");setValue(old=>old.map((value)=>{ if(value.key==key){ value.text = str } return value}))}