CoronaEnterprise.2013.1251 - iOS 7 Korean native.newTextField input Problem.

On iOS, Korean text broken at end of input characters.

(I tested with iPhone5 + iOS 7 latest version and don’t know what version works normal)

For example, when I input “안녕” (means “Hi”) and touch ok button, textField.text outputs “안녀ㅇ”.

If I input “안녕_” (underbar could be space or number or alphabet or anything…), then it outputs correctly.

Android works good.

User have to input Korean characters for nickname and chatting system.

This is critical issue because we are planning to launch the game soon.

Thank you.

Hi @zetaloki4,

Does this occur only when using Korean characters, or does the same behavior occur with Western alphabet characters? This may be related to another known issue (which has a known solution), but please confirm if it’s occurring with Korean only, or with all.

Best regards,

Brent Sorrentino

Hi, Brent.

It occurs when using Korean characters. Alphabet and number chracters has no problem.

Thank you.

Hi @zetaloki4,

Can you show me the code where you’re processing (and/or saving) the text, including the event phases you’re using?

Thanks,

Brent

-- temp... local self = {} self.ui = {} ---------------------------------------     -- input field     self.ui.textField = native.newTextField( 77, 573, 650, 53, function(e)         if e.phase == "began" then             -- user begins editing textField             if system.getInfo('platformName') == 'iPhone OS' then                 self.ui.textField.y = 270             end         elseif e.phase == "ended" then             -- textField/Box loses focus             -- Hide keyboard             native.setKeyboardFocus( nil )             if system.getInfo('platformName') == 'iPhone OS' then                 self.ui.textField.y = 590             end                      elseif e.phase == "submitted" then             -- Hide keyboard             native.setKeyboardFocus( nil )             if system.getInfo('platformName') == 'iPhone OS' then                 self.ui.textField.y = 590             end                          local inputText = M.ui.textField.text                  -- OK!! SEND!!!             --M:send{ type='chat', msg=inputText }                          inputText = nil             M.ui.textField.text = ''                      elseif e.phase == "editing" then                      end     end)          self.ui.textField.align = 'left'     self.ui.textField.font = native.newFont( native.systemFont, 10 )     self.ui.textField.y = 590  

Hi @zetaloki4,

This may be related to an issue in how iOS7 works with our text input listeners, and how it can “clip” one or more characters off the end of an input string. We fixed this in a daily build post-1202, but I’m not sure it has been worked into Enterprise or not (I’d need to check with engineering).

In any case, there may be a workaround for you. In the “submitted” or “ended” phase, instead of setting your local variable “inputText” to the text field’s “.text” parameter, set it to the event’s “.target.text” parameter. Something like:

[lua]

local inputText = e.target.text

[/lua]

Of course, you’ll need to carefully test this on the actual iOS version/device that was causing an issue. You may also want to wrap this adjusted bit into the condition where you check that the “platformName” is iOS, although it probably won’t matter.

Also, on a somewhat related note (but probably not directly related to this), remember that non-Western UTF-8 characters can occupy more than 1 string length as far as Lua’s string.len() function is concerned. So, be careful that you’re not trying to clip these somewhere based on the length they appear to be. For example, a string may appear to be 8 Korean characters, but as far as Lua is concerned, that string length could be 10, 12, or more. See the “Gotcha” here: http://docs.coronalabs.com/api/library/string/len.html

Let me know how this unfolds and if you make progress on this.

Best regards,

Brent

Hi, Brent.

Thank you very much for your rapid reply :smiley:

Hi, Brent.

We tested more and tried to find solution. But, unfortunately we cannot found how to solve this issue.

(Including 2013.1256 enterprise and simulator iOS build)

Here’s my code actually using.

There’s no logic clipping, changing of string.

--... --------------------------- -- Read filter words from file local filterChat local path = system.pathForFile( 'etc/filterChat.txt', system.ResourceDirectory ) local fileObject, errStr = io.open( path, 'r' ) path = nil if fileObject == nil then     -- no file no filtering     filterChat = {} else     local filterChatStr = fileObject:read( '\*a' )     -- split into array     filterChat = lib.split( filterChatStr, '\n' )     filterChatStr = nil     io.close( fileObject ) end -- 5783 words print('filterChat count: '..#filterChat) ------------------------------------- -- Validate input string local function validateChat( str )     if str == nil or str == '' then         return false     end     if string.find(str, '[^%a%d%p%sㄱ-ㅎ가-힣]') ~= nil then         -- cannot input character except english, number, korean         lib:confirmCheck{ msg='영문, 숫자, 한글 이 외의 문자는 입력할 수 없어요', type='normal' }         return false     end     -- 글자 수     local koreanByteSize = 0     for chr in string.gfind(str, '[ㄱ-ㅎ가-힣]') do         koreanByteSize = koreanByteSize + 1     end     local normalChar = 0     for word in string.gfind(str, '[%a%d%p%s]') do         normalChar = normalChar + 1     end     local byteCount = normalChar + (koreanByteSize/3)\*2     if byteCount \> 80 then         lib:confirmCheck{ msg='입력 글자는 한글40자, 영문80자를 넘을 수 없어요', type='normal' }         return false     end     -- 금칙어 체크     for i = #filterChat, 1, -1 do         -- remove ? character from filter list         if str:find( filterChat[i]:gsub('?', '') ) ~= nil then             -- there's unallowed word             lib:confirmCheck{ msg='금칙어가 포함되어 있습니다.', type='normal' }             return false         end     end     return true end --------------------------------------- -- input field self.ui.textField = native.newTextField( 60, 590-26, 650, 53, function(e)     if e.phase == "began" then         -- user begins editing textField         if system.getInfo('platformName') == 'iPhone OS' then             e.target.y = 270         end     elseif e.phase == "ended" then         -- textField/Box loses focus         -- Hide keyboard         native.setKeyboardFocus( nil )         if system.getInfo('platformName') == 'iPhone OS' then             e.target.y = 590         end     elseif e.phase == "submitted" then         -- Hide keyboard         native.setKeyboardFocus( nil )         if system.getInfo('platformName') == 'iPhone OS' then             e.target.y = 590         end         local inputText = e.target.text         -- Validate         if not validateChat( inputText ) then             return false         end         -- OK!! SEND!!!         M:send{ type='chat', msg=inputText }         inputText = nil         e.target.text = ''     elseif e.phase == "editing" then         -- NONE     end end) self.ui.textField.align = 'left' self.ui.textField.size = 10 self.ui.textField.font = native.newFont( DEF\_FONT, 10 ) self.ui.textField.y = 590 --...

Hi @zetaloki4,

Do you have a public build or recent daily (non-Enterprise), like #1202 or #1256? If so, could you test out the Corona sample app for text fields? It’s located here:

CoronaSDK > SampleCode > Interface > NativeKeyboard

In my on-device tests using #1256 (again, non-Enterprise), I was able to get Korean characters input into a text field (using the iPhone5’s Korean keyboard), then when I re-opened the text box, the same characters were there… no clipping had occurred. I tested this with several variances of Korean characters, including ending the sentences with a period or a regular character.

So, if you can test this, it may reveal if the issue is related to Enterprise, or something else.

Thanks,

Brent

Hi, Brent.

I checked all.

The problem is textField object’s string value (textField.text). Not displaying.

You can reprise this with “NativeKeyboard” sample project replacing fieldHandler function with code bellow.

You should type the Korean character manually. Copy and paste does not occurs problem.

(Attached result screenshot.)

local function fieldHandler( textField )          local lineCount = 0          return function( event )         if ( "began" == event.phase ) then         elseif ( "ended" == event.phase ) then         elseif ( "editing" == event.phase ) then         elseif ( "submitted" == event.phase ) then             -- If you input korean text like 안녕 or 안녕하세요, displaying of text field is ok.             -- But, textField().text value would be 안녀ㅇ, 안녕하셍ㅛ that is unexpected result.             print( 'Final text value: '..textField().text ) --\> Unexpected result...                          ----------------- DEBUG: DRAW TEXT ON SCREEN ----------------             local temp = display.newText( textField().text, 0, 270 + lineCount \* 16, nil, 16 )             temp:setTextColor(0,255,0)             lineCount = lineCount + 1             ------------------------------------------------------                          -- Hide keyboard             native.setKeyboardFocus( nil )         end     end end  

screenshot.jpg

XCODE (iPhone device connected) organizer console outputs like this…

Nov  8 14:47:50 im-utaeg-i NativeKeyboard[11771] <Warning>: Final text value: 안녕하셍ㅛ

Nov  8 14:47:54 im-utaeg-i NativeKeyboard[11771] <Warning>: Final text value: 안녀ㅇ

Best regards.

OSX Mavericks 10.9

Xcode 5.0.2 (5A3005)

Corona SDK: 2013.1257 Standard version (not Enterprise)

Sample Project: NativeKeyboard (without modifications necessary)

I can confirm this behavior on iOS6 and iOS7. When entering the word ‘안녕’, it appears correctly on the display, but outputs the following to the console log on the device:

NativeKeyboard[26488] <Warning>: 안녀ㅇ

However as the OP has observed, if you enter a character after the last ‘ㅇ’ (like a space or a number), the output in the log will be correct (NativeKeyboard[26488] <Warning>: 안녕).

NOTE:

Entering Korean text when running the sample app in the Corona Simulator will crash the simulator.

Hi, Brent.

Would you mind tell me about progression for iOS textfield? or any plan to fix this.

Thank you.

Hi @zetaloki4,

We’re still checking into it; thanks for your patience and your detailed reports (and Ingemar too).

Best regards,

Brent

Hi @zetaloki4,

We have implemented a fix for this, and it should be available to you within the next couple days via a daily build.

Sincerely,

Brent

That sounds great!

Hi @zetaloki4,

Does this occur only when using Korean characters, or does the same behavior occur with Western alphabet characters? This may be related to another known issue (which has a known solution), but please confirm if it’s occurring with Korean only, or with all.

Best regards,

Brent Sorrentino

Hi, Brent.

It occurs when using Korean characters. Alphabet and number chracters has no problem.

Thank you.

Hi @zetaloki4,

Can you show me the code where you’re processing (and/or saving) the text, including the event phases you’re using?

Thanks,

Brent

-- temp... local self = {} self.ui = {} --------------------------------------- &nbsp;&nbsp;&nbsp;&nbsp;-- input field &nbsp;&nbsp;&nbsp;&nbsp;self.ui.textField = native.newTextField( 77, 573, 650, 53, function(e) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if e.phase == "began" then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- user begins editing textField &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if system.getInfo('platformName') == 'iPhone OS' then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.ui.textField.y = 270 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif e.phase == "ended" then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- textField/Box loses focus &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Hide keyboard &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; native.setKeyboardFocus( nil ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if system.getInfo('platformName') == 'iPhone OS' then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.ui.textField.y = 590 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif e.phase == "submitted" then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-- Hide keyboard &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; native.setKeyboardFocus( nil ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if system.getInfo('platformName') == 'iPhone OS' then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.ui.textField.y = 590 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;local inputText = M.ui.textField.text &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -- OK!! SEND!!! &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --M:send{ type='chat', msg=inputText } &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputText = nil &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;M.ui.textField.text = '' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;elseif e.phase == "editing" then &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp;&nbsp;&nbsp;&nbsp;end) &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;self.ui.textField.align = 'left' &nbsp;&nbsp;&nbsp;&nbsp;self.ui.textField.font = native.newFont( native.systemFont, 10 ) &nbsp;&nbsp;&nbsp;&nbsp;self.ui.textField.y = 590 &nbsp;

Hi @zetaloki4,

This may be related to an issue in how iOS7 works with our text input listeners, and how it can “clip” one or more characters off the end of an input string. We fixed this in a daily build post-1202, but I’m not sure it has been worked into Enterprise or not (I’d need to check with engineering).

In any case, there may be a workaround for you. In the “submitted” or “ended” phase, instead of setting your local variable “inputText” to the text field’s “.text” parameter, set it to the event’s “.target.text” parameter. Something like:

[lua]

local inputText = e.target.text

[/lua]

Of course, you’ll need to carefully test this on the actual iOS version/device that was causing an issue. You may also want to wrap this adjusted bit into the condition where you check that the “platformName” is iOS, although it probably won’t matter.

Also, on a somewhat related note (but probably not directly related to this), remember that non-Western UTF-8 characters can occupy more than 1 string length as far as Lua’s string.len() function is concerned. So, be careful that you’re not trying to clip these somewhere based on the length they appear to be. For example, a string may appear to be 8 Korean characters, but as far as Lua is concerned, that string length could be 10, 12, or more. See the “Gotcha” here: http://docs.coronalabs.com/api/library/string/len.html

Let me know how this unfolds and if you make progress on this.

Best regards,

Brent