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

Definition at line 206 of file shpcommon.c.

References code_pages, and num_code_pages.

Referenced by ShpLoaderOpenShape().

207 {
208  int cpglen;
209  int is_ldid = 0;
210  int num, i;
211 
212  /* Do nothing on nothing. */
213  if ( ! cpg ) return NULL;
214 
215  /* Is this an LDID string? */
216  /* If so, note it and move past the "LDID/" tag */
217  cpglen = strlen(cpg);
218  if ( strstr(cpg, "LDID/") )
219  {
220  if ( cpglen > 5 )
221  {
222  cpg += 5;
223  is_ldid = 1;
224  }
225  else
226  {
227  return NULL;
228  }
229  }
230 
231  /* Read the number */
232  num = atoi(cpg);
233 
234  /* Can we find this number in our lookup table? */
235  for ( i = is_ldid ; i < num_code_pages; i++ )
236  {
237  if ( is_ldid )
238  {
239  if ( code_pages[i].ldid == num )
240  return strdup(code_pages[i].iconv);
241  }
242  else
243  {
244  if ( code_pages[i].cpg == num )
245  return strdup(code_pages[i].iconv);
246  }
247  }
248 
249  /* Didn't find a matching entry */
250  return NULL;
251 
252 }
static code_page_entry code_pages[]
Definition: shpcommon.h:43
static int num_code_pages
Definition: shpcommon.h:38

Here is the caller graph for this function: