Encodings: Add FT_STRINGZ support for GB18030, EUC-KR

(cherry picked from commit abf3eaace8)
This commit is contained in:
John Thacker 2020-10-28 19:30:12 +00:00 committed by AndersBroman
parent 99238a0198
commit 4e0dbcbc97
1 changed files with 36 additions and 0 deletions

View File

@ -3289,6 +3289,34 @@ tvb_get_t61_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *l
return get_t61_string(scope, ptr, size);
}
static guint8 *
tvb_get_gb18030_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *lengthp)
{
guint size;
const guint8 *ptr;
size = tvb_strsize(tvb, offset);
ptr = ensure_contiguous(tvb, offset, size);
/* XXX, conversion between signed/unsigned integer */
if (lengthp)
*lengthp = size;
return get_gb18030_string(scope, ptr, size);
}
static guint8 *
tvb_get_euc_kr_stringz(wmem_allocator_t *scope, tvbuff_t *tvb, gint offset, gint *lengthp)
{
guint size;
const guint8 *ptr;
size = tvb_strsize(tvb, offset);
ptr = ensure_contiguous(tvb, offset, size);
/* XXX, conversion between signed/unsigned integer */
if (lengthp)
*lengthp = size;
return get_euc_kr_string(scope, ptr, size);
}
guint8 *
tvb_get_stringz_enc(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, gint *lengthp, const guint encoding)
{
@ -3463,6 +3491,14 @@ tvb_get_stringz_enc(wmem_allocator_t *scope, tvbuff_t *tvb, const gint offset, g
case ENC_T61:
strptr = tvb_get_t61_stringz(scope, tvb, offset, lengthp);
break;
case ENC_GB18030:
strptr = tvb_get_gb18030_stringz(scope, tvb, offset, lengthp);
break;
case ENC_EUC_KR:
strptr = tvb_get_euc_kr_stringz(scope, tvb, offset, lengthp);
break;
}
return strptr;