PostGIS  2.3.6-r@@SVN_REVISION@@
char* codepage2encoding ( const char *  cpg)

Definition at line 286 of file shpcommon.c.

References num_code_pages.

Referenced by ShpLoaderOpenShape().

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

Here is the caller graph for this function: