+\directlua{
+ luatexja.listings.insert_cb = function()
+ if not luatexja.listings.patched then
+ luatexja.listings.patched = 1
+ luatexbase.add_to_callback('process_input_buffer',
+ function(buf)
+ local ret = ''
+ for i = 1, utf.len(buf) do
+ local c = utf.sub(buf, i, i)
+ local cu = utf.byte(c)
+ if cu >= 0x80 and tex.getcatcode(cu) \string~= 13 then
+ ret = ret .. utf.char(1048575) % U+FFFFF
+ end
+ ret = ret .. c
+ end
+ return ret
+ end, 'ltj.listings_unicode', 1)
+ end
+ end
+ luatexja.listings.remove_cb = function()
+ if luatexja.listings.patched then
+ luatexja.listings.patched = nil
+ luatexbase.remove_from_callback('process_input_buffer',
+ 'ltj.listings_unicode')%
+ end
+ end}