SDL  2.0
SDL_syslocale.m File Reference
#include "../../SDL_internal.h"
#include "../SDL_syslocale.h"
#import <Foundation/Foundation.h>
+ Include dependency graph for SDL_syslocale.m:

Go to the source code of this file.

Functions

void SDL_SYS_GetPreferredLocales (char *buf, size_t buflen)
 

Function Documentation

◆ SDL_SYS_GetPreferredLocales()

void SDL_SYS_GetPreferredLocales ( char *  buf,
size_t  buflen 
)

Definition at line 28 of file SDL_syslocale.m.

29 { @autoreleasepool {
30  NSArray *languages = NSLocale.preferredLanguages;
31  size_t numlangs = 0;
32  size_t i;
33 
34  numlangs = (size_t) [languages count];
35 
36  for (i = 0; i < numlangs; i++) {
37  NSString *nsstr = [languages objectAtIndex:i];
38  size_t len;
39  char *ptr;
40 
41  if (nsstr == nil) {
42  break;
43  }
44 
45  [nsstr getCString:buf maxLength:buflen encoding:NSASCIIStringEncoding];
46  len = SDL_strlen(buf);
47 
48  // convert '-' to '_'...
49  // These are always full lang-COUNTRY, so we search from the back,
50  // so things like zh-Hant-CN find the right '-' to convert.
51  if ((ptr = SDL_strrchr(buf, '-')) != NULL) {
52  *ptr = '_';
53  }
54 
55  if (buflen <= len) {
56  *buf = '\0'; // drop this one and stop, we can't fit anymore.
57  break;
58  }
59 
60  buf += len;
61  buflen -= len;
62 
63  if (i < (numlangs - 1)) {
64  if (buflen <= 1) {
65  break; // out of room, stop looking.
66  }
67  buf[0] = ','; // add a comma between entries.
68  buf[1] = '\0';
69  buf++;
70  buflen--;
71  }
72  }
73 }}
unsigned int size_t
#define SDL_strrchr
#define SDL_strlen
GLuint GLuint GLsizei count
Definition: SDL_opengl.h:1571
GLenum GLsizei len
GLenum GLuint GLenum GLsizei const GLchar * buf
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:163
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr

References i, NULL, ptr, SDL_strlen, and SDL_strrchr.