···188188-- Simple UTF-16BE to UTF-8 conversion (ASCII only)
189189function utf16_to_utf8(buf)
190190 local out = ""
191191- for i = 0, buf:len()-1, 2 do
192192- local c = buf(i+1, 1):uint()
193193- if c == 0 then break end
194194- if c < 128 then
195195- out = out .. string.char(c)
191191+ local len = buf:len()
192192+ for i = 0, len - 2, 2 do
193193+ -- Pioneer DB strings are UTF-16BE. High byte first.
194194+ local hi = buf(i, 1):uint()
195195+ local lo = buf(i+1, 1):uint()
196196+197197+ -- Stop at first null character pair
198198+ if hi == 0 and lo == 0 then break end
199199+200200+ -- Basic ASCII conversion
201201+ if hi == 0 and lo < 128 then
202202+ out = out .. string.char(lo)
196203 else
197204 out = out .. "?"
198205 end
···218225 [7] = "Item Type",
219226 [8] = "Flags",
220227 [9] = "Artwork ID",
221221- [10] = "Position"
228228+ [10] = "Position",
229229+ [11] = "Unknown",
230230+ [12] = "Unknown"
222231 }
223232 return labels[arg_idx]
224233 elseif msg_type == 0x4201 then -- MenuFooter
···304313 local byte_len = chars * 2
305314 if len - offset >= 5 + byte_len then
306315 local str = utf16_to_utf8(buf(offset+5, byte_len))
307307- tree:add(f_db_field_str, buf(offset+5, byte_len)):set_text(prefix .. ": \"" .. str .. "\"")
316316+ -- Use f_db_field_bin for the highlight range to avoid "trailing stray chars" warning
317317+ -- caused by Wireshark's internal string dissector seeing high-byte nulls.
318318+ tree:add(f_db_field_bin, buf(offset+5, byte_len)):set_text(prefix .. ": \"" .. str .. "\"")
308319 bytes_consumed = 5 + byte_len
309320 else
310321 bytes_consumed = len - offset
···323334324335 -- TCP DB Port Discovery Response
325336 if (pkt.src_port == 12523 or pkt.dst_port == 12523) and length == 2 then
326326-327337 local tree = root:add(p_djl, buf(0, 2))
328338 pkt.cols.protocol = "PDJL (DB Port)"
329339 tree:add(f_db_port, buf(0, 2))
330340 return
331341 end
342342+332343333344334345 if length < 5 then return end