# Japanese input

**URL:** <https://forum.juce.com/t/japanese-input/2569>\
**Category:** MacOSX and iOS\
**Created:** [February 13, 2008, 6:31pm UTC](https://forum.juce.com/t/japanese-input/2569 "2008-02-13T18:31:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazzunko](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@jazzunko](https://forum.juce.com/u/jazzunko)\
**Post date:** [February 13, 2008, 6:31pm UTC](https://forum.juce.com/t/japanese-input/2569/1 "2008-02-13T18:31:08Z")

</div>

Hi Jules,

I’m trying to input Japanese character using TextEditor/Label components on Mac, but I can input only first one letter.

As for Japanese, two characters or more might be input. Probably, Korean and Chinese also have the same situation. Therefore I added the following changes.

juce\_mac\_Windowing.cpp

```auto
OSStatus handleTextInputEvent (EventRef theEvent)
{
#if	0	//	Original code
	UniChar uc;
	GetEventParameter (theEvent, kEventParamTextInputSendText, typeUnicodeText, 0, sizeof (uc), 0, &uc);

	EventRef originalEvent;
	GetEventParameter (theEvent, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0, sizeof (originalEvent), 0, &originalEvent);

	return handleKeyEvent (originalEvent, (juce_wchar) uc);

#else	//	Handle input more than 2 characters, such as Japanese, Chinese, Korean and so on...
	UniChar *text;
	UInt32 actualSize;
	GetEventParameter (theEvent, kEventParamTextInputSendText, typeUnicodeText, NULL, 0, &actualSize, NULL);
	text = (UniChar*) NewPtr(actualSize);
	GetEventParameter (theEvent, kEventParamTextInputSendText, typeUnicodeText, NULL, actualSize, NULL, text);
				
	EventRef originalEvent;
	GetEventParameter (theEvent, kEventParamTextInputSendKeyboardEvent, typeEventRef, 0, sizeof (originalEvent), 0, &originalEvent);

	UniCharCount charCount = actualSize / sizeof( UniChar );
	OSStatus result = eventNotHandledErr;
	for (int i = 0; i < charCount; ++i)
	{
		if (handleKeyEvent (originalEvent, (juce_wchar) text[i]) != eventNotHandledErr)
			result = noErr;
	}

	return result;
#endif
}
```

It seems to work properly. If possible, I would like you to fix the problem in future editions.

Programming Environment:  
Mac OS X 10.5.2 / Xcode 2.5 / JUCE v1.46 from SVN

Best regards,  
Jazzunko

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [February 14, 2008, 12:58pm UTC](https://forum.juce.com/t/japanese-input/2569/2 "2008-02-14T12:58:22Z")

</div>

Nice one, thanks, I’ll take a look at that very soon. It’s very difficult for me to test anything involving Japanese keyboards or characters!

---

<div class="post-metadata">

**Author:** ![jazzunko](https://avatars.discourse-cdn.com/v4/letter/j/b4bc9f/32.png) [@jazzunko](https://forum.juce.com/u/jazzunko)\
**Post date:** [February 14, 2008, 3:08pm UTC](https://forum.juce.com/t/japanese-input/2569/3 "2008-02-14T15:08:18Z")

</div>

Thank you, I’m looking forward to getting the version, and I’ll keep checking this improved version.  
😃
