DGK5BPVI6PAD3WK2ZB2ITMBE6WYSU3ZR7TV7RTCQ2WJQ4RGJE5RQC LXTTOB33N2HCUZFIUDRQGGBVHK2HODRG4NBLH6RXRQZDCHF27BSAC PFT5Y2ZYGQA6XXOZ5HH75WVUGA4B3KTDRHSFOZRAUKTPSFOPMNRAC IMEJA43L3OX7S5KIYLZJ4F3ITACLAA5SZBHSCIJMULCPRSW7LXBAC BULPIBEGL7TMK6CVIE7IS7WGAHGOSUJBGJSFQK542MOWGHP2ADQQC R5OKMVVCPAKL2IUMIY7A7ZMTJQZS6UWKW4EVLAVCPLPVNI5DCEYQC QYIFOHW3WDDQMK4ATY6IOSQRFHJOQ5QCPDKRC4GVGWLQEH4HGWVQC IRV65LZPHFLLYPTMLTDO6OJDHVZQJ6MFXZ45IRXRDSRSEQNO5DIAC OTIBCAUJ3KDQJLVDN3A536DLZGNRYMGJLORZVR3WLCGXGO6UGO6AC endfunction test_draw_wrapping_text_containing_non_ascii()-- draw a long line containing non-ASCIIio.write('\ntest_draw_wrapping_text_containing_non_ascii')App.screen.init{width=60, height=60}Lines = load_array{'madam I’m adam', 'xyz'} -- notice the non-ASCII apostropheLine_width = App.screen.widthCursor1 = {line=1, pos=1}Screen_top1 = {line=1, pos=1}Screen_bottom1 = {}App.draw()local y = Margin_topApp.screen.check(y, 'mada', 'F - test_draw_wrapping_text_containing_non_ascii/screen:1')y = y + Line_heightApp.screen.check(y, 'm I’', 'F - test_draw_wrapping_text_containing_non_ascii/screen:2')y = y + Line_heightApp.screen.check(y, 'm ad', 'F - test_draw_wrapping_text_containing_non_ascii/screen:3')
local b = Text.nearest_pos_less_than(frag, line_width - x)assert(b > 0) -- avoid infinite loop when window is too narrow--? print('space for '..tostring(b)..' graphemes')local frag1 = string.sub(frag, 1, b)
local bpos = Text.nearest_pos_less_than(frag, line_width - x)assert(bpos > 0) -- avoid infinite loop when window is too narrowlocal boffset = utf8.offset(frag, bpos+1) -- byte _after_ bposassert(boffset)--? print('space for '..tostring(bpos)..' graphemes, '..tostring(boffset)..' bytes')local frag1 = string.sub(frag, 1, boffset-1)