mirror of
				https://github.com/fluffle/goirc
				synced 2025-10-30 17:58:04 +00:00 
			
		
		
		
	Handle ideographic spaces (U+3000) in !tr
This commit is contained in:
		
							parent
							
								
									abdcdf56e8
								
							
						
					
					
						commit
						5b5b918445
					
				
					 1 changed files with 14 additions and 4 deletions
				
			
		|  | @ -22,10 +22,20 @@ const googleAPIKey = "ABQIAAAA6-N_jl4ETgtMf2M52JJ_WRQjQjNunkAJHIhTdFoxe8Di7fkkYh | ||||||
| func translate(conn *irc.Conn, nick *irc.Nick, args, target string) { | func translate(conn *irc.Conn, nick *irc.Nick, args, target string) { | ||||||
| 	var langPairs vector.StringVector | 	var langPairs vector.StringVector | ||||||
| 	for { | 	for { | ||||||
| 		split := strings.Split(args, " ", 2) | 		field := strings.IndexAny(args, "  ") // handle spaces and ideographic spaces (U+3000) | ||||||
| 		if len(split) == 2 && len(split[0]) == 5 && split[0][2] == '|' { | 		if field != -1 { | ||||||
| 			langPairs.Push("&langpair=" + split[0]) | 			first := args[:field] | ||||||
| 			args = split[1] | 			if len(first) == 5 && first[2] == '|' { | ||||||
|  | 				langPairs.Push("&langpair=" + first) | ||||||
|  | 				if args[field] == ' ' { | ||||||
|  | 					args = args[field+1:] | ||||||
|  | 				} else { | ||||||
|  | 					args = args[field+utf8.RuneLen(3000):] | ||||||
|  | 				} | ||||||
|  | 				fmt.Printf("'%s' '%s'\n", first, args) | ||||||
|  | 			} else { | ||||||
|  | 				break | ||||||
|  | 			} | ||||||
| 		} else { | 		} else { | ||||||
| 			break | 			break | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue