Skip to content

Commit

Permalink
Merge pull request #2921 from DennisHeimbigner/utf8dump.dmh
Browse files Browse the repository at this point in the history
Modify ncdump to print char-valued variables as utf8.
  • Loading branch information
WardF authored May 7, 2024
2 parents f5c9183 + 211538c commit 58e37e0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 161 deletions.
157 changes: 0 additions & 157 deletions .github/workflows/run_tests_s3.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/run_tests_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

name: Run Ubuntu/Linux netCDF Tests

on: [pull_request, workflow_dispatch]
on: [ pull_request, workflow_dispatch]

concurrency:
group: ${{ github.workflow}}-${{ github.head_ref }}
Expand Down
15 changes: 12 additions & 3 deletions ncdump/vardata.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#include "vardata.h"
#include "netcdf_aux.h"

/* If set, then print char variables as utf-8.
If not set, then print non-printable characters as octal.
The latter was the default before this change.
*/
#define UTF8CHARS

/* maximum len of string needed for one value of a primitive type */
#define MAX_OUTPUT_LEN 100

Expand Down Expand Up @@ -340,6 +346,7 @@ pr_tvals(
sp = vals + len;
while (len != 0 && *--sp == '\0')
len--;
/* Walk the sequence of characters and write control characters in escape form. */
for (iel = 0; iel < len; iel++) {
unsigned char uc;
switch (uc = (unsigned char)(*vals++ & 0377)) {
Expand Down Expand Up @@ -371,10 +378,12 @@ pr_tvals(
printf("\\\"");
break;
default:
if (isprint(uc))
printf("%c",uc);
else
#ifdef UTF8CHARS
if (!isprint(uc))
printf("\\%.3o",uc);
else
#endif /*UTF8CHARS*/
printf("%c",uc);
break;
}
}
Expand Down

0 comments on commit 58e37e0

Please sign in to comment.