sngrep icon indicating copy to clipboard operation
sngrep copied to clipboard

non-ascii symbols can cause display issue

Open nshopik opened this issue 8 years ago • 4 comments

SIP allow non-ascii names in some fields like From,To,contact

This appears to be cause issues when you open call flow and scroll down some text may shifted

nshopik avatar Oct 12 '17 13:10 nshopik

Yep, this is an old enhancement no easy to implement.

SIP payload is UTF-8 and we have no encoding subroutines. I will try to use ncurses wide chars to print panel payload content and see what happens. Adding wide character support for all the text will be much much harder, but we'll see.

Thanks for reporting @nshopik !!

Kaian avatar Oct 27 '17 15:10 Kaian

The proper solution for this should be supporting correctly the UTF-8 characters, but the actual code is not ready for handling encodings (even if compiled with Unicode support) so I'll add a very basic enhancement to replace non-ascii characters with a . This character can be replaced for whatever you prefer using the cr.nonascii setting in your sngreprc file.

Full UTF-8 support is till a TODO and a goal for future releases :)

Regards!

Kaian avatar Apr 05 '18 10:04 Kaian

ui_manager.c

// Put next character in position
if (isascii(payload[i])) {
    mvwaddch(win, line, column++, payload[i]);
} else {
    //mvwaddch(win, line, column++, *nonascii);
    int len = 0, j=i;
    while (payload[i]!='"') len += (payload[i++] & 0xc0) != 0x80;
    mvwaddnstr(win, line, column, &payload[j], i-j);
    i--;
    column += len;
}

EZ

aoeuh avatar May 17 '18 16:05 aoeuh

Hi, I just want to thank @aoeuh as the code above really works. You just need to make sure you have UTF-8 locale set like this:

takeshi:sngrep$ echo $LANG
en_US.UTF-8

I added it to my fork mrcp_support branch.

Here is a snapshot of sngrep showing an MRCP SPEAK message with Japanese Text properly rendered:

sngrep_with_unicode_support

(obs: please ignore the date 2019/09/24. This is from an old pcap file that I've been using as reference for testing).

MayamaTakeshi avatar Mar 21 '21 05:03 MayamaTakeshi