URL Encoding | Google Maps Platform
文章推薦指數: 80 %
In HTML forms, the character = is used to separate a name from a value. The URI generic syntax uses URL encoding to deal with this problem, while HTML forms ... Google MapsPlatform Overview Products Pricing Documentation GetStarted GetStartedwithGoogleMapsPlatform APIPicker Billing&Pricing Reporting&Monitoring MapIDs FAQ SupportandResources IncidentManagement Maps MapsJavaScriptAPI MapsSDKforAndroid MapsSDKforiOS MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs MapsElevationAPI Routes DirectionsAPI DistanceMatrixAPI RoadsAPI RoutesAPI(Preview) Solutions IndustrySolutions GamingServices TransportationandLogistics Places PlacesAPI PlacesSDKforAndroid PlacesSDKforiOS PlacesLibrary,MapsJavaScriptAPI GeocodingAPI GeolocationAPI TimeZoneAPI AdditionalResources APISecurityBestPractices MapCoverageDetails OptimizationGuide MobileOSandsoftwaresupport Launchstages Deprecations AssetTrackingPlan URLEncoding WordPressUsers Blog Community StackOverflow GitHub YouTube Discord Twitter IssueTracker English BahasaIndonesia Deutsch Español Español–AméricaLatina Français Italiano Polski Português–Brasil TiếngViệt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文–简体 中文–繁體 日本語 한국어 Signin Documentation Google MapsPlatform Overview Products Pricing Documentation More Blog Community More GoogleMapsPlatformDocumentation GetStarted GetStartedwithGoogleMapsPlatform APIPicker MapIDs FAQ SupportandResources IncidentManagement BestPractices APIsecuritybestpracticesOptimizationGuideOptimizingWebServiceUsage Billing&Pricing Billing&PricingOverview Billing Pricing PublicPrograms Reporting&Monitoring Reporting&MonitoringOverview Reporting Monitoring Utilities EncodedPolylineAlgorithmFormat InteractivePolylineEncoderUtility Maps MapsJavaScriptAPI MapsSDKforAndroid MapsSDKforiOS MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs Routes DirectionsAPI DistanceMatrixAPI RoadsAPI Places PlacesAPI PlacesSDKforAndroid PlacesSDKforiOS PlacesLibrary,MapsJavaScriptAPI GeocodingAPI GeolocationAPI TimeZoneAPI ElevationAPI Solutions IndustrySolutions Retail GamingServices AdditionalResources MapCoverageDetails MobileOSandsoftwaresupport Launchstages Deprecations AssetTrackingPlan RootCAMigrationFAQ Domains Projectrolescomparison Pre-LaunchChecklist PremiumPlan URLEncoding WordPressUsers GetStarted GetStartedwithGoogleMapsPlatform APIPicker Billing&Pricing Reporting&Monitoring MapIDs FAQ SupportandResources IncidentManagement Maps MapsJavaScriptAPI MapsSDKforAndroid MapsSDKforiOS MapsStaticAPI StreetViewStaticAPI MapsEmbedAPI MapsURLs MapsElevationAPI Routes DirectionsAPI DistanceMatrixAPI RoadsAPI RoutesAPI(Preview) Solutions IndustrySolutions GamingServices TransportationandLogistics Places PlacesAPI PlacesSDKforAndroid PlacesSDKforiOS PlacesLibrary,MapsJavaScriptAPI GeocodingAPI GeolocationAPI TimeZoneAPI AdditionalResources APISecurityBestPractices MapCoverageDetails OptimizationGuide MobileOSandsoftwaresupport Launchstages Deprecations AssetTrackingPlan URLEncoding WordPressUsers StackOverflow GitHub YouTube Discord Twitter IssueTracker Home Products GoogleMapsPlatform Documentation Sendfeedback URLEncoding Stayorganizedwithcollections Saveandcategorizecontentbasedonyourpreferences. SomecharacterscannotbepartofaURL(forexample,thespace)andsomeother charactershaveaspecialmeaninginaURL.InHTMLforms,thecharacter=is usedtoseparateanamefromavalue.TheURIgenericsyntaxusesURLencoding todealwiththisproblem,whileHTMLformsmakesomeadditionalsubstitutions ratherthanapplyingpercentencodingforallsuchcharacters. Forexample,spacesinastringareeitherencodedwith%20orreplacedwith theplussign(+).Ifyouuseapipecharacter(|)asaseparator,besure toencodethepipeas%7C.Acommainastringshouldbeencodedas%2C. Itisrecommendedyouuseyourplatform'snormalURLbuildinglibrariesto automaticallyencodeyourURLs,toensuretheURLsareproperlyescapedforyour platform. BuildingavalidURL Youmaythinkthata"valid"URLisself-evident,but that'snotquitethecase.AURLenteredwithinanaddressbarina browser,forexample,maycontainspecialcharacters(e.g. "上海+中國");thebrowserneedstointernallytranslate thosecharactersintoadifferentencodingbeforetransmission. Bythesametoken,anycodethatgeneratesoracceptsUTF-8input mighttreatURLswithUTF-8charactersas"valid",butwouldalsoneed totranslatethosecharactersbeforesendingthemouttoawebserver. Thisprocessiscalled URL-encodingorpercent-encoding. Specialcharacters Weneedtotranslatespecialcharactersbecause allURLsneedtoconformtothesyntaxspecifiedbythe Uniform ResourceIdentifier(URI)specification.Ineffect,thismeansthatURLs mustcontainonlyaspecialsubsetofASCIIcharacters:thefamiliar alphanumericsymbols,andsomereservedcharactersforuseascontrol characterswithinURLs.Thistablesummarizesthesecharacters: SummaryofValidURLCharacters SetcharactersURLusage Alphanumeric abcdefghijklm nopqrstuvwxyz ABCDEFGHIJKLM NOPQRSTUVWXYZ 0123456789 Textstrings,schemeusage(http),port(8080),etc. Unreserved -_.~ Textstrings Reserved !*'();:@&=+$,/?%#[] Controlcharactersand/orTextStrings WhenbuildingavalidURL,youmustensurethatitcontainsonlythosecharactersshowninthe SummaryofValidURLCharacterstable.ConformingaURLtousethissetofcharactersgenerally leadstotwoissues,oneofomissionandoneofsubstitution: Charactersthatyouwishtohandleexistoutsideofthe aboveset.Forexample,charactersinforeignlanguages suchas上海+中國needtobeencodedusingthe abovecharacters.Bypopularconvention,spaces(whichare notallowedwithinURLs)areoftenrepresentedusingtheplus '+'characteraswell. Charactersexistwithintheabovesetasreservedcharacters, butneedtobeusedliterally. Forexample,?isusedwithinURLstoindicate thebeginningofthequerystring;ifyouwishtousethe string"?andtheMysterions,"you'dneedtoencodethe '?'character. AllcharacterstobeURL-encodedareencoded usinga'%'characterandatwo-characterhex valuecorrespondingtotheirUTF-8character.Forexample, 上海+中國inUTF-8wouldbeURL-encodedas %E4%B8%8A%E6%B5%B7%2B%E4%B8%AD%E5%9C%8B.The string?andtheMysterianswouldbeURL-encodedas %3F+and+the+Mysteriansor%3F%20and%20the%20Mysterians. Commoncharactersthatneedencoding Somecommoncharactersthatmustbeencodedare: Unsafecharacter Encodedvalue Space %20 " %22 < %3C > %3E # %23 % %25 | %7C ConvertingaURLthatyoureceivefromuserinputissometimes tricky.Forexample,ausermayenteranaddressas"5th&MainSt." Generally,youshouldconstructyourURLfromitsparts,treating anyuserinputasliteralcharacters. Additionally,URLsarelimitedto8192charactersforallGoogleMapsPlatformwebservices andstaticwebAPIs.Formostservices,thischaracterlimitwillseldombeapproached.However, notethatcertainserviceshaveseveralparametersthatmayresultinlongURLs. Sendfeedback Exceptasotherwisenoted,thecontentofthispageislicensedundertheCreativeCommonsAttribution4.0License,andcodesamplesarelicensedundertheApache2.0License.Fordetails,seetheGoogleDevelopersSitePolicies.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2022-10-10UTC. [{ "type":"thumb-down", "id":"missingTheInformationINeed", "label":"MissingtheinformationIneed" },{ "type":"thumb-down", "id":"tooComplicatedTooManySteps", "label":"Toocomplicated/toomanysteps" },{ "type":"thumb-down", "id":"outOfDate", "label":"Outofdate" },{ "type":"thumb-down", "id":"samplesCodeIssue", "label":"Samples/codeissue" },{ "type":"thumb-down", "id":"otherDown", "label":"Other" }] [{ "type":"thumb-up", "id":"easyToUnderstand", "label":"Easytounderstand" },{ "type":"thumb-up", "id":"solvedMyProblem", "label":"Solvedmyproblem" },{ "type":"thumb-up", "id":"otherUp", "label":"Other" }] Needtotellusmore? StackOverflow Askaquestionunderthegoogle-mapstag. GitHub Forkoursamplesandtrythemyourself. Discord ChatwithfellowdevelopersaboutGoogleMapsPlatform. IssueTracker Somethingwrong?Sendusabugreport! LearnMore FAQ APIPicker Tutorials Platforms Android iOS Web WebServices ProductInfo PricingandPlans ContactSales Support TermsofService Android Chrome Firebase GoogleCloudPlatform Allproducts Terms Privacy SignupfortheGoogleDevelopersnewsletter Subscribe English BahasaIndonesia Deutsch Español Español–AméricaLatina Français Italiano Polski Português–Brasil TiếngViệt Türkçe Русский עברית العربيّة فارسی हिंदी বাংলা ภาษาไทย 中文–简体 中文–繁體 日本語 한국어
延伸文章資訊
- 1438464 - json displayed with wrong encoding (i.e. not unicode)
This seems a pretty fundamental issue.. Many people use Chrome to inspect the JSON output of HTTP...
- 2Set Character Encoding
This extension modifies http response headers to override original character set, so when install...
- 3UTF-8 Problem - Google Groups
everytime I try to convert a UTF8 text I get questionsmarks except of ... The standard character ...
- 4Charset
Due to the low frequency of use, Google Chrome removed the ability to manually set the webpage en...
- 5Encoding settings for garbled text - Google Support
Navigate to the page you're having trouble viewing. Right-click on the page. Mouse over "Encoding...