PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ codepage2encoding()

char* codepage2encoding ( const char *  cpg)

Definition at line 292 of file shpcommon.c.

293 {
294  int cpglen;
295  int is_ldid = 0;
296  int num, i;
297 
298  /* Do nothing on nothing. */
299  if ( ! cpg ) return NULL;
300 
301  /* Is this an LDID string? */
302  /* If so, note it and move past the "LDID/" tag */
303  cpglen = strlen(cpg);
304  if ( strstr(cpg, "LDID/") )
305  {
306  if ( cpglen > 5 )
307  {
308  cpg += 5;
309  is_ldid = 1;
310  }
311  else
312  {
313  return NULL;
314  }
315  }
316 
317  /* Read the number */
318  num = atoi(cpg);
319 
320  /* Can we find this number in our lookup table? */
321  for ( i = is_ldid ; i < num_code_pages; i++ )
322  {
323  if ( is_ldid )
324  {
325  if ( code_pages[i].ldid == num )
326  return strdup(code_pages[i].iconv);
327  }
328  else
329  {
330  if ( code_pages[i].cpg == num )
331  return strdup(code_pages[i].iconv);
332  }
333  }
334 
335  /* Didn't find a matching entry */
336  return NULL;
337 
338 }
static int num_code_pages
Definition: shpcommon.c:35
static code_page_entry code_pages[]
Definition: shpcommon.c:40

References code_pages, and num_code_pages.

Referenced by ShpLoaderOpenShape().

Here is the caller graph for this function: