Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: 영문 자판을 한글 자판으로 수정하는 함수 #60

Closed
99mini opened this issue Apr 18, 2024 · 2 comments · Fixed by #68
Closed

[Feature]: 영문 자판을 한글 자판으로 수정하는 함수 #60

99mini opened this issue Apr 18, 2024 · 2 comments · Fixed by #68

Comments

@99mini
Copy link
Contributor

99mini commented Apr 18, 2024

Description

영문 자판으로 입력하면 그에 상응하는 한글 자모 string을 반환해주는 기능을 가진 함수.

Possible Solution

영문 자판과 한글 자판을 맵핑하는 상수 객체를 선언하여 구현하면 될 거 같습니다.

// constants.ts
/*
 * 영문 대소문자를 구분한 자판 맵 객체
 */
export const KEBOARD_MAP = {
  q: 'ㅂ',
  Q: 'ㅃ',
  w: 'ㅈ',
  //...한/영 자판 맵핑
} as const;
// convertEnglishToHangul.ts
import { KEBOARD_MAP } from './constants';
import { disassembleHangul } from './disassemble';

/**
 * 영문 자판인 경우 한글 자판으로 치환합니다. 그렇지 않은 경우 입력 문자를 반환합니다. 
 * @param 한글로 변환하고자 하는 영문 자판.
 * @returns 한글 자모로 변환된 문자열
 */
export function convertEngKeboardToHangul(engKeyboardText: string): string {
    return engKeyboardText.split('').map((inputText) => keyboardMap[inputText] ?? disassembleHangul(inputText)).join; 
}

etc.

#18 문자 배열을 입력 받아 한글로 함성하는 함수와 함께 이용하면 영타로 입력된 값을 온전한 한글로 치환할 수 있을 것으로 기대합니다.

combineHangulCharacter(...convertEngKeboardToHangul('vm').split('')) // Output '프'
combineHangulCharacter(...convertEngKeboardToHangul('fhs').split('')) // Output '론'
@okinawaa
Copy link
Member

오 이거 너무 좋은 것 같아요!

@99mini
Copy link
Contributor Author

99mini commented Apr 19, 2024

오 이거 너무 좋은 것 같아요!

감사합니다! PR도 작성하도록 하겠습니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants