Repository: nvaccess/nvda

Issue:
Delayed descriptions for characters on cursor movement and Chinese characters
First of all I would like to say, I am not sure if this is a bug, please correct me if I am wrong.


### Steps to reproduce:
1. enabled the function Delayed descriptions for characters on cursor movement of the latest nvda beta, 2023.1 beta1, 
2. open a notepad and type some Chinese words, e.g. 香港
3. I try switching to Chinese Taiwan and Chinese Hong Kong locale to test this function
4. under each of the locale I use  arrow keys to move the edit cursor to check the character descriptions
5. the character description reported by nvda beta is the same for both of the characters in Chinese Taiwan and Chinese Hong Kong locale (where using the enhance phonetic addon switching locale will generate different character description)
6. Under both locale, nvda beta only reported the first available character description of both of the characters here (where using the enhance phonetic addon switching locale will report all of the available character descriptions)

Specifically using the character 港 as an example.
Using the nvda beta here, the character description for 港 is "香港" under hk and tw locale
but using the enhance phonetic reading addon, the character description under hk locale is "港	香港	港澳	港口	海港	商港	軍港	漁港	港區	港務局	轉運港	駐港領事館" and under tw locale is "港	港口	港灣	香港	海港	避風港	高雄港	(左半三點水，右半巷口的巷)"

### Actual behavior:

### Expected behavior:
1. as Chinese locale has different character description under different locale, the character description being reported should be based on the current locale of the nvda
2. I am not sure if it is an intended function of the pull request to only report the first available character description instead of reporting all the available character description of a character, but I would really appreciate the nvda core to retain the function of enhance phonetic reading to report all available character description 

### NVDA logs, crash dumps and other attachments:

### System configuration
#### NVDA installed/portable/running from source:
portable

#### NVDA version:
nvda 2022.3 beta 1
#### Windows version:
windows 10 home ed 21h2
#### Name and version of other software in use when reproducing the issue:

#### Other information about your system:

### Other questions
#### Does the issue still occur after restarting your computer?
not tried
#### Have you tried any other versions of NVDA? If so, please report their behaviors.
not tried
#### If NVDA add-ons are disabled, is your problem still occurring?
this is a nvda portable version without any addon
#### Does the issue still occur after you run the COM Registration Fixing Tool in NVDA's tools menu?
not tried


Discussion:

Resolving patch:
diff --git a/source/speech/speech.py b/source/speech/speech.py
--- a/source/speech/speech.py
+++ b/source/speech/speech.py
@@ -295,7 +295,13 @@ def _getSpellingSpeechWithoutCharMode(
 		sayCapForCapitals: bool,
 		capPitchChange: int,
 		beepForCapitals: bool,
+		fallbackToCharIfNoDescription: bool = True,
 ) -> Generator[SequenceItemT, None, None]:
+	"""
+	@param fallbackToCharIfNoDescription: Only applies if useCharacterDescriptions is True.
+	If fallbackToCharIfNoDescription is True, and no character description is found,
+	the character itself will be announced. Otherwise, nothing will be spoken.
+	"""
 	
 	defaultLanguage=getCurrentLanguage()
 	if not locale or (not config.conf['speech']['autoDialectSwitching'] and locale.split('_')[0]==defaultLanguage.split('_')[0]):
@@ -309,7 +315,6 @@ def _getSpellingSpeechWithoutCharMode(
 		text=text.rstrip()
 
 	textLength=len(text)
-	count = 0
 	localeHasConjuncts = True if locale.split('_',1)[0] in LANGS_WITH_CONJUNCT_CHARS else False
 	charDescList = getCharDescListFromText(text,locale) if localeHasConjuncts else text
 	for item in charDescList:
@@ -326,6 +331,8 @@ def _getSpellingSpeechWithoutCharMode(
 		if useCharacterDescriptions and charDesc:
 			IDEOGRAPHIC_COMMA = u"\u3001"
 			speakCharAs=charDesc[0] if textLength>1 else IDEOGRAPHIC_COMMA.join(charDesc)
+		elif useCharacterDescriptions and not charDesc and not fallbackToCharIfNoDescription:
+			return None
 		else:
 			speakCharAs=characterProcessing.processSpeechSymbol(locale,speakCharAs)
 		if config.conf['speech']['autoLanguageSwitching']:
@@ -361,23 +368,15 @@ def getSingleCharDescription(
 		capPitchChange = synthConfig["capPitchChange"]
 	else:
 		capPitchChange = 0
-	defaultLanguage = getCurrentLanguage()
-	if not locale or (
-		not config.conf['speech']['autoDialectSwitching']
-		and locale.split('_')[0] == defaultLanguage.split('_')[0]
-	):
-		locale = defaultLanguage
-	# If the description for the locale is unknown, we yield nothing.
-	char, description = getCharDescListFromText(text, locale=locale)[0]
-	uppercase = char.isupper()
-	if description is None:
-		return
 	yield BreakCommand(getSingleCharDescriptionDelayMS())
-	yield from _getSpellingCharAddCapNotification(
-		description[0],
-		sayCapForCapitals=uppercase and synthConfig["sayCapForCapitals"],
-		capPitchChange=(capPitchChange if uppercase else 0),
-		beepForCapitals=uppercase and synthConfig["beepForCapitals"],
+	yield from _getSpellingSpeechWithoutCharMode(
+		text,
+		locale,
+		useCharacterDescriptions=True,
+		sayCapForCapitals=text.isupper() and synthConfig["sayCapForCapitals"],
+		capPitchChange=(capPitchChange if text.isupper() else 0),
+		beepForCapitals=text.isupper() and synthConfig["beepForCapitals"],
+		fallbackToCharIfNoDescription=False,
 	)
 
 


Test patch: