728x90

 

 

charAt()

charAt 은 문자열에서 인자로 주어진 값에 해당하는 문자를 리턴합니다.

 

문법

JAVASCRIPT

charAt(index)

Copy

 

인자

  • index - 필수
  • 0보다 큰 정수

 

 

설명(description)

문자열에 속하는 문자는 왼쪽부터 오른쪽까지 0부터 인덱싱되어 있습니다. 

charAt은 index로 주어진 값에 해당하는 문자를 리턴합니다. 

인덱스는 0부터 시작하기 때문에 index로 들어갈 수 있는 가장 큰 수는 (문자열.legnth-1)이다. 존재하지 않는 index를 인자로 전달하면 공백이 출력됩니다.

charAt 는 index에 해당하는 문자를 리턴하고, chartCodeAt은 유니코드 값을 리턴하는 차이가 있다.

 

예제 코드

JAVASCRIPT

charAt(index)

 

 

 

charCodeAt()

charCodeAt 메서드는 index에 해당하는 문자의 unicode 값을 리턴합니다.

 

문법(Syntax)

JAVASCRIPT

string.charCodeAt(index)

Copy

 

인자

  • ndex - 필수
  • 0보다 큰 정수

 

설명(description)

유니코드는 모든 시스템에서 일관되게 문자를 표현하기 위한 산업표준입니다. 

charCodeAt은 주어진 index에 해당하는 유니코드 값을 리턴하는데 이 값은 unicode가 지원되는 모든 시스템에서 동일한 문자를 가르킵니다. 

charAt는 index에 해당하는 문자를 리턴하고, chartCodeAt은 유니코드 값을 리턴하는 차이가 있습니다.

 

예제 코드

JAVASCRIPT

var stringName = '자바스크립트'; console.log(stringName.charCodeAt(0)); // 51088 // http://www.unicode.org/charts/PDF/UAC00.pdf 에서 '자'을 찾아보면 'C790'인데 이것은 16진수다. // 이를 10진수로 변환하면 51088 된다.

Copy

 

 

참고 관련 링크

  1. 유니코드
  2. 한글에 대한 유니코드

 

 

 



출처: https://webclub.tistory.com/329 [Web Club]

728x90

LiquidCrystal and Adafruit SSD1306(SSH1102) Collison Detected

- Library Collision, may be not distingsh between two I2C Sensors, LCD and OLED.

 

Trouble Shooting Processing Start..

728x90

[Time]

설명

매개변수에 지정된 시간(마이크로 초)동안 프로그램을 멈춘다. 1밀리초는 1000 마이크로 초, 1초는 100만 마이크로 초. 현재, 정확한 delay를 만드는 가장 큰 값은 16383. 미래의 아두이노 릴리스에서 바뀔 수 있다. delay 가 몇 천 마이크로 초 보다 길면, 대신 delay() 를 써야 한다.

문법

delayMicroseconds(us)

매개변수

us: 멈출 마이크로 초 (unsigned int)

반환

없음

예제 코드

이 코드는 핀번호 8이 출력 핀으로 동작하도록 구성한다. 약 100 마이크로 초의 펄스 열을 보낸다. 근사값은 코드에서 다른 명령 실행으로 인한 것이다.

 

int outPin = 8;               // 디지털 핀 8

void setup() {
  pinMode(outPin, OUTPUT);    // 디지털 핀을 출력으로
}

void loop() {
  digitalWrite(outPin, HIGH); // 핀을 켠다
  delayMicroseconds(50);      // 50 마이크로 초 쉰다
  digitalWrite(outPin, LOW);  // 핀을 끈다
  delayMicroseconds(50);      // 50 마이크로 초 쉰다
}

주의와 경고

이 함수는 3 마이크로 초 이상 범위에서 매우 정확하게 돌아간다. delayMicroseconds 가 작은 지연시간동안 정확히 수행한다고 보장할 수 없다. 아두이노 0018 현재, delayMicroseconds() 는 더이상 인터럽트를 비활성화 하지 않는다.

728x90

42

4

I use curly braces with all of my switch case statements in C/Objective-C/C++

I had not, until a few moments ago, considered whether including the break; statement inside the braces was good or bad practice. I suspect that it doesn't matter, but I figure it is still worth asking.

 

 

 

 

 

Just a give a slightly more detailed answer...

The official C99 specification says the following about the break statement:

A break statement terminates execution of the smallest enclosing switch or iteration statement.

So it really doesn't matter. As for me, I put the break inside the curly braces. Since you can also have breaks in other places inside your curly braces, it's more logical to also have the ending break inside the braces. Kind of like the return statement.

 

 

 

+ Recent posts